This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes JSP and the fly likes How to kill the session on browser close Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » JSP
Bookmark "How to kill the session on browser close " Watch "How to kill the session on browser close " New topic
Author

How to kill the session on browser close

anmol kumar
Greenhorn

Joined: Apr 22, 2004
Posts: 2
I want to kill the session on browser closes using java.
i.e, want to capture the event on the browser closes and then kill the session.


anmol
Ali Gohar
Ranch Hand

Joined: Mar 18, 2004
Posts: 572
you can invalidate the session using session.invalidate() method.
Nathaniel Stoddard
Ranch Hand

Joined: May 29, 2003
Posts: 1258
Anmol,
Browsers don't tell servers that the user is closing her browser though. You would have to try some sort of JavaScript for that solution. If you can manage that, only then could you invalidate the session.


Nathaniel Stodard<br />SCJP, SCJD, SCWCD, SCBCD, SCDJWS, ICAD, ICSD, ICED
Jeanne Boyarsky
internet detective
Marshal

Joined: May 26, 2003
Posts: 30068
    
149

Submitting to the server on browser close only works in IE. Search the HTML forum for details. It's been discussed there serveral times.


[Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Blogging on Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, OCAJP, OCPJP beta, TOGAF part 1 and part 2
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: How to kill the session on browser close
 
Similar Threads
Killing session on closing a browser
Destroy session when close browser.
calling a javascript function on closing browser
session handling in case of abnormal shutdown
Killing session when closing the browser