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 detect when an include in a jsp occurs in a web
I want to create a Thread safe JSP page. It is possible in Servlet
I want to ask a question about the JSP. I writing the following code
I have a JSP page that handles file downloads. I set the response header
Related to this question: URL characters replacement in JSP with UrlRewrite I want to
I want to create a client side mail creator web page. I know the
I have two pages one is the main page and the another one is
I have the JSP file (/page.jsp) in the root of my app directory. I
What are the scoping rules for variables in a jsp page with pages added
So I have a main JSP index page, index.jsp, which has several includes. Something

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.