Satinder Singh [
http://community.jboss.org/people/satinder_2000] created the discussion
"HttpSession in JBoss 7 issue"
To view the discussion, visit:
http://community.jboss.org/message/616898#616898
--------------------------------------------------------------
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>
--------------------------------------------------------------
Reply to this message by going to Community
[
http://community.jboss.org/message/616898#616898]
Start a new discussion in JBoss AS7 Development at Community
[
http://community.jboss.org/choose-container!input.jspa?contentType=1&...]