aspose file tools*
The moose likes EJB and other Java EE Technologies and the fly likes JavaScript window close event... Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Java » EJB and other Java EE Technologies
Bookmark "JavaScript window close event..." Watch "JavaScript window close event..." New topic
Author

JavaScript window close event...

Ravi Davu
Greenhorn

Joined: May 24, 2005
Posts: 1
Hello,

How to capture the event when the user closes the window?
I need to submit the form to server to invalidate the session.

Friends, I tried with onunload javascript function.Its working fine but its closing the window even when the user moving to another window.

Thanks,

Ravi.
Lakshmi Anantharaman
Ranch Hand

Joined: Aug 01, 2001
Posts: 58
Hi Ravi

I do not know if this question belongs here ... but

I believe that this is impossible . The very reason being HTTP is stateless . When the window object is closed there are no events to capture this . That is the idea of having an explicit logout item that you can capture . Another way would be to write a HTTP Sessionbinding listener . Here the value unbound event will be raised when the session expires (window with no activity for a set amount of time ) then you may be able to do a session invalidate.

You may be able to search about widow close in either the servlet or jsp forum to get many leads

Hope this helps
Lakshmi Anantharaman
[ May 24, 2005: Message edited by: Laksh Anan ]
ashishagarwal agarwal
Greenhorn

Joined: May 04, 2006
Posts: 4
Hello Ravi,
I am also looking for the same query. If you get answer please do help me too.

for this nodoubt we have to use javascript since window event cannot be handled by jsp or servlet. So, what we need is to establish communication between client programming (java script) and server programming (jsp etc). Answer is provided bye AJAX technology, which allows client program to communicate with server programming objects.

I have no idea about AJAX, if you find something reply back.

Regards
Ashish
 
wood burning stoves
 
subject: JavaScript window close event...
 
Similar Threads
How to make user logout when user closes browser window?
javascript to capture event for restore down or maximize
How to catch browser minimized event
Calling a JavaScript function after the completion of a Struts action
which event will fires before closing the browser window