This content has been marked as final.
Show 2 replies
-
2. Re: HttpSession in JBoss 7 issue
satinder_2000 Jul 22, 2011 12:40 AM (in response to jaikiran)Thanks. will try. but worrying.
I set an attribute in an HttpSession (in Servlet) and tried to read the same in the subsequent Servlet call. But the session returns a null value for the parameter. Am I missing something? The same code works fine in JBoss 6 and Glassfish.
The simple code is as below:
String mode=request.getParameter("mode");
String message=null;
if (mode.equals("1")){
HttpSession session=request.getSession(true);
session.setAttribute("SOMEPARAM", "SOMEVAL");
message="Value set in session "+session.getAttribute("SOMEPARAM");
}else if (mode.equals("2")){
HttpSession session=request.getSession(true);
message="Value read from session "+session.getAttribute("SOMEPARAM");
}
PrintWriter pw=response.getWriter();
pw.print("<html><head><title>Test Session</title></head><body><h1>"+message+"</h1>");
pw.print("</body></html>");
pw.flush();
And a very simple JSP to invoke this
<p><a href="/TestJBoss/TestServlet?mode=1">Write to Session</a></p>
<p><a href="/TestJBoss/TestServlet?mode=2">Read from Session</a></p>
Thanks. will try. but worrying.