Win a copy of Java Concurrency Live Lessons this week in the Threads forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Session retrieval in the event of browser close  RSS feed

 
Raghav Sam
Ranch Hand
Posts: 412
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In the event of my browser crashing or being closed inadvertently, I need to retrieve the session data and save it to a database. What are the best possible ways in doing this assuming my session times out only after some time (say, 30 mins) ?

------------------
Raghav.
 
Peter den Haan
author
Ranch Hand
Posts: 3252
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Have the objects that represent session state implement HttpSessionBindingListener. That way, they can take appropriate action if/when they are unbound (e.g. because the session expires).
- Peter
 
Raghav Sam
Ranch Hand
Posts: 412
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Peter den Haan:
Have the objects that represent session state implement HttpSessionBindingListener. That way, they can take appropriate action if/when they are unbound (e.g. because the session expires).
- Peter

I just looked into it. But I am not sure how I should go about it. For example, if I have some order info and I am putting this into session, will I make that servlet implement HttpSessionBindingListener?

------------------
Raghav.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!