| 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
|
 |
 |
|
|
subject: Saving data at the time of session timing out
|
|
|