Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Mistery dissapearance of a session!?

Status
Not open for further replies.

navrsalemile

Programmer
Feb 6, 2005
62
CA
I have a class which sets session parameters using
session.putValue( "param1", "value1");
session.putValue("param2", "value2");

and then redirects to a JSP page:

response.sendRedirect( "
somepage.jsp retrieves session params using this scriptlet:

<%
String param1 = "";
Object o = pageContext.getAttribute("param1", PageContext.SESSION_SCOPE );
if ( o != null ) {
param1 = o.toString();
out.println("param1 = " + param1);
}
String param2 = "";
o = pageContext.getAttribute("param2", PageContext.SESSION_SCOPE );
if ( o != null ) {
param2 = o.toString();
out.println("param1 = " + param2);
}
%>
...
<%@ include file="header.jsp" %>
...
<%
if (param2.compareTo("") != 0 ) {
out.flush();
pageContext.include( "welcome_" + param2 + ".jsp );
}
else {
out.println( "page not included")
%>
...
<%
if (param1.compareTo("") != 0) {
out.flush();
pageContext.include( param1 + ".jsp" );
else {
%>
...
<%@ include file="footer.jsp" %>

But the attributes retrieved from session here are nulls as I get message "page not included".
Isn't sendRedirect() supposed to preserve the session and only create a new http request!?

thanks,
mile
 
There is a dedicated forum for JSP/Servlet posts. It is forum695

Tim
---------------------------
"Your morbid fear of losing,
destroys the lives you're using." - Ozzy
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top