• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

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

 
Ranch Hand
Posts: 977
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Ranch Hand
Posts: 1467
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Ranch Hand
Posts: 149
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 1467
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 977
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
reply
    Bookmark Topic Watch Topic
  • New Topic