This week's book giveaway is in the Android forum.
We're giving away four copies of Head First Android and have Dawn & David Griffiths on-line!
See this thread for details.
The moose likes JSF and the fly likes How to do logout when browser closes in jsf Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Head First Android this week in the Android forum!
JavaRanch » Java Forums » Java » JSF
Bookmark "How to do logout when browser closes in jsf" Watch "How to do logout when browser closes in jsf" New topic

How to do logout when browser closes in jsf

siva prasa

Joined: Feb 16, 2010
Posts: 25
How to do logout and session invalidate when the user closes the browser in between the application using JSF???Any ideas welcome....
Hany Shafik
Ranch Hand

Joined: Jun 21, 2008
Posts: 80
While it may be possible to register an event listener to be called back when the browser closes using JavaScript (Howerver most of the time it doesn't wok perfectly), You can't rely on such mechanism as the browser may shutdown due to crash or even worse the network connection may get disconnected for any reason before issuing the request to invalidate your session.
That is why you must rely on having a session timeout as your reliable mechanism to invalidate your session.
However there are cases that it is essential for you to know whether the client is still active or have navigated away (e.g. Webbased chat application). In such cases due to the statelessness of the HTTP protocol, you can make the browser continuesly poll the server to let the server know that he or she is still alive, but this may consume your network resources.
I agree. Here's the link:
subject: How to do logout when browser closes in jsf
It's not a secret anymore!