File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Servlets and the fly likes Browser closing detection for session handling Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "Browser closing detection for session handling" Watch "Browser closing detection for session handling" New topic
Author

Browser closing detection for session handling

Ricardo Celma
Greenhorn

Joined: May 19, 2011
Posts: 2
I know that this post perhaps belongs to the javascript forum, but I need some help to invalidate a session.

Currently I have used HttpSessionListener to find if the session has timed out or the user has used the logout button.

What I want to do is to detect when the user closes the tab/window where my application is, in order to destroy the session, so he/she can log again if the user opens another window (only one session per user is allowed).

I know that in Firefox I can use the onclose event to send that information to the server, but I also need to do it in Internet Explorer and chrome (at least).

Care to share any suggestions? Thank you very much in advance.
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61433
    
  67

Welcome to the Ranch.

Please SearchFirst. You will find that this issue has been discussed dozens of times, and that the conclusion is always that you cannot detect when the browser is closing, and you must rely on the session timeout to allow the session to invalidate itself when the timeout expires.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Ricardo Celma
Greenhorn

Joined: May 19, 2011
Posts: 2
thank you very much.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Browser closing detection for session handling