my dog learned polymorphism*
The moose likes Servlets and the fly likes Losing object reference in sessions Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "Losing object reference in sessions" Watch "Losing object reference in sessions" New topic

Losing object reference in sessions

Heather Danielson

Joined: Jun 12, 2002
Posts: 3
I have a bean (OrderValues) on the session that contains many vectors to store information from an HTML form. If I have only one session running, all of my data is retrieved correctly, however, when I'm running multiple sessions( i.e. multiple browser instances) all of my session data is retrieved correctly except from one vector that is storing object references. The object references returned are those that belonged to the last session to hit the web server (Tomcat 4.0.3). Any ideas on what I can do to correct this problem?
William Brogden
Author and all-around good cowpoke

Joined: Mar 22, 2000
Posts: 12760
One would immediately suspect that there is only one instance of the Vector in question in the entire application. Where does it get created?
Heather Danielson

Joined: Jun 12, 2002
Posts: 3
For a new session I call a servlet that creates a new OrderValues bean ( this bean contains all the Vectors). The constructor for the OrderValues bean sets each of the Vectors to "new Vector();". This bean is then placed on the session Object. I have double checked my code to be sure that the Vector in question ( subscriberInfo) is in fact being set to a "new Vector();".
The subscriberInfo Vector stores objects of type Subscriber, and I have the Subscriber objects on the session Object as well.
I'm obviously doing something incorrectly, but I can't find it yet. Any help is much appreciated!
Heather Danielson

Joined: Jun 12, 2002
Posts: 3
Alas, I have found my coding error: I instantiated the subscriberInfo Vector as a static variable. Must've been a brain fart! Thanks for all your help!
I agree. Here's the link:
subject: Losing object reference in sessions
Similar Threads
Siteminder Session
How to maintain/preserve session between applications on same AS?
Session Objects
Attributes, Session and ServletContext
Concurrent session and caching