aspose file tools*
The moose likes Servlets and the fly likes Session re-visited Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "Session re-visited" Watch "Session re-visited" New topic
Author

Session re-visited

Malhar Barai
Author
Ranch Hand

Joined: Aug 17, 2001
Posts: 399
Hi all,
How do I keep the session alive even after the browser window is closed...do I state some time or there some other way too ??
hope I am clear.
TIA
MB


Malhar Barai
SOA & Java Book
Ken Robinson
Ranch Hand

Joined: Dec 23, 2003
Posts: 101
Usually, in a vendor specific way, you can configure how long the timeout of a Session is. The server has no idea the browser has closed, so the timeout is usually used to force the 'dead' Session to die after a period of inactivity.
If this is what you are looking for, you will have to search the vendors docs to see how to set this in the server you are using.
Malhar Barai
Author
Ranch Hand

Joined: Aug 17, 2001
Posts: 399
Hi,
What we usually find is whenever the browser is re-launched, we find a new session id...is there any way in which we can retain the same session id ??
And in that way, can we retain the info stored in session ??
Maybe this is what I am looking for.
TIA
MB
Anonymous
Ranch Hand

Joined: Nov 22, 2008
Posts: 18944
create a Hashtable in application sope.
put the session there.. send a cookie valid for 2 days for ex.
close the browser.
reopen the browser. read the cookie there. Look up within the HashTable in the appln scope. get that session...
Ben Dover
Ranch Hand

Joined: Jan 30, 2004
Posts: 91
Originally posted by R�stem e Zal:
create a Hashtable in application sope.
put the session there.. send a cookie valid for 2 days for ex.
close the browser.
reopen the browser. read the cookie there. Look up within the HashTable in the appln scope. get that session...

Hi R�stem,
out of curiosity, does this object in application scope persist if container restarts or server crashes?
William Brogden
Author and all-around good cowpoke
Rancher

Joined: Mar 22, 2000
Posts: 12784
    
    5
create a Hashtable in application sope.
put the session there.. send a cookie valid for 2 days for ex.
close the browser.
reopen the browser. read the cookie there. Look up within the HashTable in the appln scope. get that session...

Not a good idea - a session object should be managed by the servlet container only. When you looked after the session expired you would find that it had been invalidated and all the managed links were probably garbage.
However you could make your own custom object to hold whatever needs to be held and save that. If you make it serializable you could write it to disk and recover it later.
Louis - you would have to make specific code provision to persist the object.
Bill
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Session re-visited