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!