Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Java > Java and JDK > Pro JSP
|
Pro JSP Advanced JSP coding questions. Beginning questions will be redirected to the Beginning JSP forum.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Pro JSP section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old June 6th, 2005, 01:42 PM
Registered User
 
Join Date: Jun 2005
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default Mistery dissapearance of a session!?

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( "http://localhost:8889/app/somepage.jsp")

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!?

I tried with encodeURL(), no success.
I ensured IE accept all cookies, again no success. Do not know what else to try?

thanks,
mile
 
Old June 16th, 2005, 06:21 AM
Registered User
 
Join Date: Jun 2005
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi,

Does the URL of your page which execute the response.sendRedirect is 127.0.0.1:8889 (or <machine_name>:8889) instead of localhost:8889 ?

If yes, it is the reason why you loose your session, you have to keep the same IP address throughout your JSP apps.

Pipou





Similar Threads
Thread Thread Starter Forum Replies Last Post
Session nook ASP.NET 1.x and 2.0 Application Design 1 July 19th, 2007 02:45 PM
about session sureshaec ASP.NET 2.0 Basics 1 June 6th, 2007 01:24 AM
session lakshmi devi Classic ASP Basics 4 July 20th, 2006 04:33 AM
Mistery dissapearance of a session navrsale JSP Basics 0 June 6th, 2005 02:23 PM
session and cookie problem (empty session file) msincan BOOK: Beginning PHP, Apache, MySQL Web Development ISBN: 978-0-7645-5744-6 0 February 27th, 2005 05:31 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.