• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Jeanne Boyarsky
  • Ron McLeod
Sheriffs:
  • Paul Clapham
  • Liutauras Vilda
  • Devaka Cooray
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
Bartenders:

Session Value Persistence

 
Ranch Hand
Posts: 230
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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!
 
Bartender
Posts: 6663
5
MyEclipse IDE Firefox Browser Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Ranch Hand
Posts: 1514
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Then you need to first verify the default that your container uses for the age os a session.
 
You didn't tell me he was so big. Unlike this tiny ad:
Smokeless wood heat with a rocket mass heater
https://woodheat.net
reply
    Bookmark Topic Watch Topic
  • New Topic