aspose file tools*
The moose likes JSP and the fly likes How to Execute Session Destroying code in jsp Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSP
Bookmark "How to Execute Session Destroying code in jsp" Watch "How to Execute Session Destroying code in jsp" New topic
Author

How to Execute Session Destroying code in jsp

vishal avad
Ranch Hand

Joined: Nov 29, 2001
Posts: 45
when my some bean is holding the scope session. and my user does
not properly logs out instead he presses cross button of the browser. directly then how could i log him out.
or if power goes down.
is there any solution other than using timeout?
Manas Ahlaad
Ranch Hand

Joined: Nov 07, 2001
Posts: 165
hi
there is HttpSessionBindingListener which can be associated to a session , it will notify you when session is expired and started.
or else i dont think there is nothing to notify the events such as browser closing, power off


Manas<br />Today If You are not Confused,You are just not thinking Clearly !<br />---------------------------------
vishal avad
Ranch Hand

Joined: Nov 29, 2001
Posts: 45
thx manas
my question is how to write a code which will be automatically executed when a session is closed in any of the possible ways
sanjay yermalkar
Greenhorn

Joined: Sep 19, 2001
Posts: 23
When the session expires (or invalidates), it calls valueUnbound() method on all the bound objects implementing HttpSessionBindingListener. So, you can write a class which implements HttpSessionBindingListener and
have the valueUnbound() method execute the cleanup rutine.
vishal avad
Ranch Hand

Joined: Nov 29, 2001
Posts: 45
thx sanjay
i will try this and get back
thx again

vishal
Manas Ahlaad
Ranch Hand

Joined: Nov 07, 2001
Posts: 165
hi sanjay & avad,
valueUnbound() is called when the session expires , but closing the browser does not let the session expire.
If the browser is closed , the session object stays at the server for quite sometime (the idle time specified for the servlet specified in the web.xml file) , if the instance of the servlet idle upto the time then the server removed the instance from container thus causing the session to expire.
try specifying short time in web.xml file
manas
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: How to Execute Session Destroying code in jsp