wood burning stoves 2.0*
The moose likes Servlets and the fly likes How to recover values from an old session???(Is it possible??) Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "How to recover values from an old session???(Is it possible??)" Watch "How to recover values from an old session???(Is it possible??)" New topic
Author

How to recover values from an old session???(Is it possible??)

Marcos Maia
Ranch Hand

Joined: Jan 06, 2001
Posts: 977
I�d like to recover a value from an old session when a new one is created but I don�t know how to do it. Could someone please help me.
maha anna
Ranch Hand

Joined: Jan 31, 2000
Posts: 1467
How do you create a new session? Using request.getSession(true) ?
This statement supposed to return the ols session if one exists already. Are you using oldSession.invalidate() before creating a new session to clear off the old session?
If you want to see if an old one exists, write request.getSession(false) and see if it is not null. If use of "false" arg returns some session obj, (not null), then grab those session values associated with oldSession.

regds
maha anna
Maky Chopra
Ranch Hand

Joined: Apr 11, 2001
Posts: 149
but since he si "accidently" creating a new session object, doesnt he lose his reference to the old one ? IMHO, the old session object will be ripely waiting for gc.
maha anna
Ranch Hand

Joined: Jan 31, 2000
Posts: 1467
That's what I am not clear about. How one can accidently create a new session. We can create a new session with request.getSession(true) right? According to API it should return the old one if there was one already existing.
To make sure to make the old one gcd and create a new one, we have to purposly invalidate the old session if one exists and then user request.getSession(true);
I didn't rely/check on this "true argument returning the old session if one exists -concept". I just use (true) in only one place where I want to create a new session, an din all other places use (false) argument.
Even in the place where I use (true), I first check with "false" argument, if it is null , go for "true" arg. Otherwise, invalidate the old one and use "true" aru to create a fresh one.
regds
maha anna
[This message has been edited by maha anna (edited April 27, 2001).]
Marcos Maia
Ranch Hand

Joined: Jan 06, 2001
Posts: 977
Thanks for the atention,
well I think i solve the problem, in fact i didn�t have time to test the program yet, cause here in Brazil it�s already 6pm and I have to go to University.
About a new session I believe that a new one was being created cause I had some global variables, I�ve changed the code but like I said I didn�t have the time to test yet, I hope it was just this.
Anyway thank�s a lot.
JavaRanch is the coolest place in internet.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: How to recover values from an old session???(Is it possible??)
 
Similar Threads
backup
Some questions from the chapter 5: flow control, exceptions and assertions.
recover application direcory from bean
How to replicate sessions between two web applications on the same tomcat?
problems whith session variables