*
The moose likes JSP and the fly likes How to invaliddate session when browser Window is closed using [x] button Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Java » JSP
Reply locked New topic
Author

How to invaliddate session when browser Window is closed using [x] button

Mahesh cosmolite
Greenhorn

Joined: Sep 19, 2011
Posts: 1
Hi Forum,

I want to invalidate session when browser is closed by end user using [x] button on LHS or double click on RHS.

Regards
Mahesh
Anuj Batra
Greenhorn

Joined: Sep 18, 2011
Posts: 24
I do not think there is a cross browser event handler available. but for IE onUnload works.
so place the function <body onUnload="function logout()">

function logout() {
<%session.inValidate();%>
}
jeya velan
Greenhorn

Joined: Feb 07, 2011
Posts: 9

Anuj Batra wrote:
function logout() {
<%session.inValidate();%>
}


You can not make a javascript function to execute a scriptlet.
You can call the logout URL using javscript which will do the work.
But you can't be sure.
There is no guarntee that onunload will execute properly.
olivier dutranoit
Ranch Hand

Joined: Aug 20, 2011
Posts: 81

let the session timeout do its work.
or put a < a href = ""> url to a logout servlet on the page.
do not try to capture browser events.
bad idea.
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61309
    
  66

This has been discussed dozens of times. Please SearchFirst.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
 
GeeCON Prague 2014
 
subject: How to invaliddate session when browser Window is closed using [x] button