File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Servlets and the fly likes session.invalidate Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "session.invalidate" Watch "session.invalidate" New topic


amit ang
Ranch Hand

Joined: Sep 28, 2001
Posts: 38
Hi All,
Can anyone help me?
I have implemented HttpSessionListener and have implemented the methods for Create and Destroy the session.
now when i hit the page with a browser i get the message from the Create method. But, when i close the browser i don't get the message from the Destroy method (I hope when you close the browser the session should be invalidated).
Any seggestions?
Thanks in Advance
Bosun Bello
Ranch Hand

Joined: Nov 06, 2000
Posts: 1510
No, the session will not be invalidated when you close the browser. There is no way for the server to know when the browser closes. If the server tries to send a response then an exception will be thrown. You can use JavaScript to determine when the browser window is being closed and then meybe send a message to the backend to indicate that.

So much trouble in the world -- Bob Marley
Engin Okucu
Ranch Hand

Joined: Feb 09, 2002
Posts: 174
i'm intersted to try it with destroy method.
But i have any knowledge with Javascript. Can your reply to write the code(Javascript) to do it ?
Thank you.
I agree. Here's the link:
subject: session.invalidate
It's not a secret anymore!