File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes JSP and the fly likes session tracking Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSP
Bookmark "session tracking" Watch "session tracking" New topic

session tracking

Alan Shiers
Ranch Hand

Joined: Sep 24, 2003
Posts: 237
Hi there,

I have a strange problem you may be able to shed some light on. At least I hope so. I'm working with an existing project using JSP's and Servlets and a backend MySQL database. The project entails the ability to perform ad hoc queries to the database. The source code files can be found at the bottom of the page at:

The project contains one servlet called and a bean called The Control servlet is first invoked using a POST call. In doing so, a Session object is created and an instance of QueryBean is created and stored in the Session object. The QueryBean contains the meta data for the database. A jsp called QueryInput.jsp loads and at the same time also activates a second browser window loading MetaTables.jsp. When MetaTables.jsp loads in the second window it calls
QueryBean qb = (QueryBean)session.getAttribute("qBean");
from the session object retrieving the QueryBean instance and the meta data is used to be displayed in a table. The first time this process occurs everything is fine, until I dismiss the window containing MetaTables.jsp.

Here's what happens...QueryInput.jsp has a button on it. It is used to re-display the window that MetaTables.jsp loads into if the user dismisses that window when it first loads. Here's where the interesting part comes in. If I click on the button in the main browser window containing QueryInput.jsp the second browser window appears alright, but for whatever reason all the data that was in the QueryBean instance is gone. MetaTables.jsp loads and attempts to obtain the QueryBean instance again from the Session object, but there is no data to display. It's gone!

What's going on? Does anybody know?

Alan Shiers
Ranch Hand

Joined: Sep 24, 2003
Posts: 237
I tried posting some code, but your system refused to accept it for some reason. I kept getting an error page that recommended replacing all "<" symbols from my code, which I did. But that didn't help.
Tien-Chih Wang

Joined: Feb 23, 2003
Posts: 25
The session object in seems like a local object.
you can construct another HttpSession in your jsp page and print out all the Values by using getAttributeNames() to see what's going on.

Tien-Chih Wang
[ May 05, 2005: Message edited by: Tien-Chih Wang ]
It is sorta covered in the JavaRanch Style Guide.
subject: session tracking
It's not a secret anymore!