wood burning stoves 2.0*
The moose likes JSP and the fly likes Saving data at the time of session timing out 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 "Saving data at the time of session timing out" Watch "Saving data at the time of session timing out" New topic
Author

Saving data at the time of session timing out

Mrigasira Srinivas
Greenhorn

Joined: Feb 28, 2001
Posts: 17
Hello All,
I am working on a web-based application that has a series of forms that the user fills out. If the session were to time out, I need to save the data entered by the user before logging him/her out. Can anyone tell me how this can be done? Any kind of help in this regard - including source code - would be much appreciated.
Thanks
Val Pecaoco
Ranch Hand

Joined: Dec 05, 2001
Posts: 156
Hi Yamini,
You can have a JSP instantiating a JavaBean that is bound in the Session object. This JavaBean then implements the HttpSessionBindingListener interface, which means it will have a "valueUnbound()" method "...that is called when the instance is unbound, which typically happens when the session is invalidated because the user logged out or was inactive for too long..." (from Java Examples in a Nutshell, 2/e (p. 482) by David Flanagan) You can then have code under "valueUnbound()" that saves data to a file or database.
The above-mentioned book has a downloadable example zip file from the O'Reilly Web site, which includes an application utilizing HttpSessionBindingListener.
GL
Ex Animo Java!
-- Val


"Knowledge is power, but enthusiasm is the key." -- Lavern Barn
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Saving data at the time of session timing out
 
Similar Threads
Session Deletion help.
Session timeouts and listeners....
time out
Performance question based on two cases
Close window on JSP Session TIME-OUT