This week's book giveaways are in the Java EE and JavaScript forums.
We're giving away four copies each of The Java EE 7 Tutorial Volume 1 or Volume 2(winners choice) and jQuery UI in Action and have the authors on-line!
See this thread and this one for details.
The moose likes Servlets and the fly likes HttpSessionListener if browser is closed Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "HttpSessionListener if browser is closed" Watch "HttpSessionListener if browser is closed" New topic
Author

HttpSessionListener if browser is closed

Arshad Azeem
Greenhorn

Joined: Aug 21, 2005
Posts: 13
Hi,

Is the sessionDestroyed(HttpSessionEvent event) method in our implementation of HttpSessionListener supposed to be called if the browser is closed? I think it shouldn't be and will not be, but can anyone please confirm?

Thanks,
Arshad.
Bauke Scholtz
Ranch Hand

Joined: Oct 08, 2006
Posts: 2458
It is supposed to be called if the session is destroyed.

The session will be destroyed when HttpSession#invalidate() is called, either manually by coding or "automatically" by the webcontainer when the session is timed out.
Arshad Azeem
Greenhorn

Joined: Aug 21, 2005
Posts: 13
question is...doesn't the session end when the browser is closed
Sunil Vasudevan
Ranch Hand

Joined: Mar 05, 2007
Posts: 107
Server does not know about user closing the browser. So the session won't end. The session will still be active on the server till the session times out.


Sunil.V<br />SCJP2, SCWCD1.4, SCBCD1.3
Bauke Scholtz
Ranch Hand

Joined: Oct 08, 2006
Posts: 2458
Arshad Azeem wrote:question is...doesn't the session end when the browser is closed
Stuff doesn't work that way, no.
 
jQuery in Action, 2nd edition
 
subject: HttpSessionListener if browser is closed