• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Liutauras Vilda
  • Henry Wong
  • Devaka Cooray
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Al Hobbs
  • Carey Brown
Bartenders:
  • Piet Souris
  • Mikalai Zaikin
  • Himai Minh

Saving data at the time of session timing out

 
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Ranch Hand
Posts: 156
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
reply
    Bookmark Topic Watch Topic
  • New Topic