aspose file tools*
The moose likes JSP and the fly likes Session Value Persistence Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSP
Bookmark "Session Value Persistence" Watch "Session Value Persistence" New topic
Author

Session Value Persistence

Manikandan Jayaraman
Ranch Hand

Joined: Sep 15, 2004
Posts: 230
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!


Regards,<br />Mani<br />SCJP 1.4 (95%)<br />SCWCD 1.4 (94%)
Deepak Bala
Bartender

Joined: Feb 24, 2006
Posts: 6661
    
    5

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()


SCJP 6 articles - SCJP 5/6 mock exams - More SCJP Mocks
Manikandan Jayaraman
Ranch Hand

Joined: Sep 15, 2004
Posts: 230
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

Joined: Nov 06, 2000
Posts: 1510
Then you need to first verify the default that your container uses for the age os a session.


Bosun (SCJP, SCWCD)
So much trouble in the world -- Bob Marley
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Session Value Persistence