Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3427100
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T06:47:44+00:00 2026-05-18T06:47:44+00:00

I want my JSP page to include another page based on a value in

  • 0

I want my JSP page to include another page based on a value in the Request.
So i set the following:

    request.setAttribute("chosenLang", "NL");
    RequestDispatcher dispatcher = request.getRequestDispatcher(address);
    dispatcher.forward(request, response);

And when i get to the ‘address’ page i try to do the following:

<c:choose>
    <c:when test="${chosenLang eq 'NL'}">
        <%@include file="/Localization/NL_Localization.jsp" %>
    </c:when>
    <c:otherwise>
        <%@include file="/Localization/EN_Localization.jsp" %>
    </c:otherwise>
</c:choose>

So, i know the chosenLang finds the ‘NL’ attribute, because when I change whats between the and tags to <c:out value="Test" /> it works, I see the test get mentioned on my page, and when i put 2 values in there, one for NL and one for some other language, it changes aswell..

The real error though, comes when I try to use a string that’s defined in one of the Localization.jsp files, like so:

<%
String welcomeStr="this is defining String variable";
%>

And when I call that string somewhere down in my page like

 <%=welcomeStr%>

my IDE doesnt warn me that there’s something wrong. But when I compile and run I get the following error:

org.apache.jasper.JasperException: Unable to compile class for JSP: 

An error occurred at line: 48 in the jsp file: /index3.jsp
welcomeStr cannot be resolved
45:                     <li>My courses</li>
46:                     <li>My messages [1]</li>
47:                     <li>My details</li>
48:                     <li> <%=welcomeStr%></li>
49:                 </ul>
50:             </div>
51:             <div id="menuHolder">

So, what am I missing here?
Or is this done more convenient in another way?

Thanks in advance!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-18T06:47:44+00:00Added an answer on May 18, 2026 at 6:47 am

    Try looking at ResourceBundle. What this will allow you to do is write 1 JSP file, and all the wording on the page will be controlled in property files. This will avoid you having to write logic in your jsp file to control the language.

    Your JSP page can read from property files, each of which will have your wording for different languages/countries.

    There are lots of tutorials out there on how to use ResourceBundle. Here is one from Oracle

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to conditionally include a css file in my jsp page based on
I want to include jQuery UI in my jsp page. I tried this <jsp:root
i have put fckeditor in jsp page. I want to get the value whatever
I am passing param value in include tag in jsp page like below <s:include
This is my folder Structure I want to include the page common/tray.jsp form plan/add_edit.jsp
I want to make include jspf into index jsp page , these statements <%--
I'm using Spring MVC. I want to include menu page (named menu.jsp) with a
I'm learning JSP and I want to include subpage (on div named content) based
I want to create a Thread safe JSP page. It is possible in Servlet
I want to display the data retrieved from the JSP page in my List.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.