Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Session Value Persistence

 
Manikandan Jayaraman
Ranch Hand
Posts: 230
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All,

I have a file A.jsp(say), which takes a number as input. This page directs to B.jsp, where I store this number into the Session from request.getParameter().

B.jsp has a request dispatcher to c.jsp. C.jsp has a FORM ACTION=D.jsp.

In D.jsp however, when I try to retrieve the session value, it says null. What could be the reason?

Please help!
 
Deepak Bala
Bartender
Posts: 6663
5
Firefox Browser Linux MyEclipse IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What is this session's age ? Can you post some code ? Why dont you write an object that implements the session binding listener so you know when it gets unbound ? Just in case the session is being invalidated without you calling invalidate()
 
Manikandan Jayaraman
Ranch Hand
Posts: 230
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have not set any AGE fot session. Nothing in DD or in my code. Code Sample Below:

===
step_1_controller.jsp
===
<%@page import="java.util.*" %>

<%
String s1 = "";
s1 = request.getParameter("application");
session.setAttribute("Application",s1);

String s2 = request.getParameter("bg_instances");
session.setAttribute("numServers",s2);
session.setAttribute("numServersBackup",s2);
ArrayList phyServers = new ArrayList(Integer.parseInt((String)session.getAttribute("numServers")));
session.setAttribute("phyServers",phyServers);


request.getRequestDispatcher("/jsp/portfolio_gen/step_2_controller.jsp").forward(request,response);
%>
===

===
step_2_controller.jsp
===
<%
if(Integer.parseInt((String)session.getAttribute("numServers"))!= 0)
{
%>

<form action="step_3_controller.jsp" method="POST">

<%
int numServersVal = Integer.parseInt((String)session.getAttribute("numServers")) - 1 ;
String s = ""+numServersVal;
session.setAttribute("numServers",s);
%>

<%@include file="/jsp/portfolio_gen/PhysicalServerView.jspf" %>

<input type="submit" value="next" />
</form>
<%
}
else
request.getRequestDispatcher("/jsp/portfolio_gen/step_4_controller.jsp").forward(request,response);
%>

====

====
step_3_controller.jsp
====
<jsp:useBean id="phyServer" class="com.ibm.in.model.PhysicalServer" />

<jsp:setProperty name="phyServer" property="serverName" value='<%=request.getParameter("p_sName")%>' />
<jsp:setProperty name="phyServer" property="serverType" value='<%=request.getParameter("p_sType")%>' />
<jsp:setProperty name="phyServer" property="serverGenre" value='<%=request.getParameter("p_sGenre")%>' />
<jsp:setProperty name="phyServer" property="serverIP" value='<%=request.getParameter("p_sIP")%>' />
<jsp:setProperty name="phyServer" property="userName" value='<%=request.getParameter("p_sUser")%>' />
<jsp:setProperty name="phyServer" property="password" value='<%=request.getParameter("p_sPass")%>' />
<jsp:setProperty name="phyServer" property="howToAccess" value='<%=request.getParameter("p_sAccess")%>' />
<jsp:setProperty name="phyServer" property="directoriesForApp" value='<%=request.getParameter("p_sRefer")%>' />

<%
ArrayList phyServers = (ArrayList) session.getAttribute("phyServers");
System.out.println("phySevers :"+phyServers);
phyServers.add(phyServer);
session.setAttribute("phyServers",phyServers);

request.getRequestDispatcher("/jsp/portfolio_gen/step_2_controller.jsp").forward(request,response);

%>

======================
in step_3_controller.jsp, last but FOURTH line "System.out.println("phySevers :"+phyServers);" GIVES ME NULL.
 
Bosun Bello
Ranch Hand
Posts: 1510
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Then you need to first verify the default that your container uses for the age os a session.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic