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

sessions

david allen
Ranch Hand

Joined: Sep 27, 2002
Posts: 185
Hi all,
Just a quick question on sessions. I am working on a site that adds a few different objects to the session. For example, User, Album and a few other values. What I want is for the session to expire only when the browser is closed and not if the user does not use the browser for say 15 min.
I have tried session.setMaxInactiveInterval(-1) but that does not seem to do it.
Anyone know how to do it?
Regards david
Andres Gonzalez
Ranch Hand

Joined: Nov 27, 2001
Posts: 1561
Have you tried using session-timeout tag in your web.xml.
If you set it with 0 it means that the session will never expire.


I'm not going to be a Rock Star. I'm going to be a LEGEND! --Freddie Mercury
Sainudheen Mydeen
Ranch Hand

Joined: Aug 18, 2003
Posts: 218
Hi
You can set session-timeout tag (web.xml) to a value to 0 or less
Thanks
Sainudheen
david allen
Ranch Hand

Joined: Sep 27, 2002
Posts: 185
So if I edit the web.xml file so that the session tag is set to zero does this mean a session will only expire when the server is stopped?
What I am after is having the session expire when the browser is closed? Is this possible?
Regards
David
Stan James
(instanceof Sidekick)
Ranch Hand

Joined: Jan 29, 2003
Posts: 8791
Sadly the browser does not tell the server when it closes. I don't think you can tell the difference between a)user closed the browser b)user went out for dinner & dancing or c)user is busily surfing other sites.
If you really, really gotta know (really!) you can put an applet in the browser and have it send "I'm still here!" messages to the server or have the server send "Are you still there?" messages to the applet. We're buying a vendor product that does this so it can synchronize telephony events and workflow availability with the browser. We're buying it because it ain't easy to build!


A good question is never answered. It is not a bolt to be tightened into place but a seed to be planted and to bear more seed toward the hope of greening the landscape of the idea. John Ciardi
William Brogden
Author and all-around good cowpoke
Rancher

Joined: Mar 22, 2000
Posts: 12821
    
    5
I don't think that "never expire" is what you want - if the servlet engine serializes sessions to disk, your hard drive will just accumulate sessions.
A "keep alive" pulse with JavaScript or applet sounds right for you - then you can let the servlet engine dispose of sessions normally.
Bill
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: sessions