I have written a class that store connection information for a user, such as UserID, Password, etc. This class is getting instanciated by my application at the point a user logs in. Everything works fine until another user logs in. Once this happens, the previous information is overwritten, as if using the same instance, instead of creating a new one. I am developing in JSP and am storing the class in the session variable. Anyone have any thoughts on why this would happen or how to prevent it? I am instanciating the class as follows: db2Connect myConnection = new db2Connect(); I then do session.setAttribute("connection", myConnection); to store the connection object in my session. I retrieve it using: db2Connect myConnection = new db2Connect(); myConnection = (db2Connect) session.getAttribute("connection"); db2Connect is the class I wrote. The above is not copy/paste code, so ignore any syntax errors. Thanks, Jason.
Jason, It looks like your session variable (setAttributte method) is behaving like a java.util.Properties object. The java.util.Properties object extends from a java.util.Hashtable which stores key/value pairs. The keys are unique and if you insert the same key with a different value, then the last insert clobbers in previous value with the same key. Here are some suggestions to fix your problem. 1. Don't use the setAttribute method. 2. Create your own map collection using the UserID as the key. -Peter
Joined: Jan 25, 2001
Yes, they are logging on with IE 5.
Joined: Feb 08, 2001
What I meant is: are the users logging in from separate browsers? I just wont to verify that there's a separate session object for each user.