Hey all,
I'm new to JSP/JSTL, and I have the following problem:
I have a page1.jsp with the following code:
<c:if test="${not empty param.username}">
<%
String name = request.getParameter("username");
System.out.print(name);
session.setAttribute("username", name);
%>
<c:redirect url="/page2.jsp"/>
</c:if>
And a page2.jsp with the following code:
<c:if test="${empty sessionContext.username}">
<c:redirect url="/page1.jsp"/>
</c:if>
What it should do is, page1 directs to page2 if a user has entered a username, otherwise it stays on page1.
Page2 should check for a username in the SessionScope so that people who manually type in CONTEXT/page2.jsp are redirected to page1 to provide a username.
I have, however the problem that all my session attributes get lost after the call of c:redirect in page1.
Is that intended?
If so, is there a fix for it (I know ways to do it eventually, but I wanted to use the JSTL EL a bit, and I don't think one should lose all his session attributes on a redirect, right?)
Edited by: sunami on Jan 10, 2010 5:50 AM