jQuery in Action, 3rd edition
The moose likes Servlets and the fly likes lost session attribute on src JSP's Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "lost session attribute on src JSP Watch "lost session attribute on src JSP New topic

lost session attribute on src JSP's

James Inge

Joined: Dec 04, 2000
Posts: 12
Hi All,
I have been wrestling with this subtle one for most of today...
I have a JSP that includes a couple of other JSP's, so that my servlet can always post to the same JSP and dynamically include a header and the body. Eg Main.jsp
<frameset cols='230,*' border='0' framespacing='0'
frameborder='NO'><frame src='header.jsp' name='header'><frame
src=body.jsp' name='body'></frameset>
My problem is that I need to extract a class that I populate with all the necessary data from the session implicit object in the two included JSP pages. The implicit session object in Main.jsp contains the class I need to extract, but neither header.jsp or body.jsp can get to that class. I have checked this in the two included JSP's by outputing the value of all the session object values by extracting them using session.getValueNames and writing these out. It contains nothing.
I have checked that the object I am trying to extract has session scope, because I can see it in Main.jsp.
This has me stumped. I am using Tomcat 3.2.3
Please help me.
William Brogden
Author and all-around good cowpoke

Joined: Mar 22, 2000
Posts: 13018
Are all of these pages in an application that has been set up in the server.xml file?
If it was me, I would try using URLs for the pages that include the application root.
author of:
Ranch Hand

Joined: Nov 22, 2008
Posts: 18944
Are you testing with cookies enabled in your browser? If not, then you should encodeURL the two src values.
Miftah Khan
- Sun Certified Programmer for the Java 2 Platform
- Sun Certified Web Component Developer for the J2EE Platform
James Inge

Joined: Dec 04, 2000
Posts: 12
Thankyou for your replies.
I added the full path to the JSP references, but still no joy. I also used encodeURL to add the session reference, but the session is gone when I check it in header and body JSP's. I think that the session has been invalidated and thus cleared.
I have gotten a bit further on where my problem is, but still can't work it out.
If I use the jsp:include tag to add my header and body in my page then I have no problems with my session object. But using the src attribute of frame is where the session object goes missing.
Do you think I have a Tomcat configuration problem?
I agree. Here's the link: http://aspose.com/file-tools
subject: lost session attribute on src JSP's
It's not a secret anymore!