• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How to Handle timeout to save user input

 
Christopher McCauley
Greenhorn
Posts: 27
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Greetings to All,

I have a problem that I believe has already been solved womewhere but I am not sure how to find the solution or cure it.

When a users session timesout, then they issue a submit. It fails because of an attribute that was in the session is missing. The submit would work if the attributes in the session were refreshed, but I need to know when the session has timed out. How might I save the (html) form they had filled out, have them log in again and then return to that page and issue the same submit?



Thanks for any suggestions.
mccools


[ May 26, 2005: Message edited by: Christopher McCauley ]
 
Adeel Ansari
Ranch Hand
Posts: 2874
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
session-timeout under session-config element in web.xml define the value of session timeout. we can overwrite it using setMaxInactiveInterval() method of HttpSession.
 
Sharad Agarwal
Ranch Hand
Posts: 167
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Christopher McCauley:
How might I save the (html) form they had filled out, have them log in again and then return to that page and issue the same submit?
[ May 26, 2005: Message edited by: Christopher McCauley ]


Translate the form parameters into a bean on the server and save it in the session. Once you have performed the authorization process, read the bean and pre-populate the form for the user. Does this address the question or was there something else you were looking for?
 
William Brogden
Author and all-around good cowpoke
Rancher
Posts: 13064
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If I understand the problem, you want to preserve a partially filled out form contents past the expiration of a session.
If you keep the contents in a JavaBean type object, where the object implements the HttpSessionBindingListener, the object will get notified when the session is being destroyed.
At that point you might serialize the bean to disk or otherwise save the state. Obviously there will have to be some mechanism to recover the bean when they log back in.
Bill
 
Adeel Ansari
Ranch Hand
Posts: 2874
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Or simply make it, session-timeout, -1.
 
William Brogden
Author and all-around good cowpoke
Rancher
Posts: 13064
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If the session never times out and you depend on every user specifically logging out for clean up, you will eventually clog the system with old abandoned sessions.
 
Christopher McCauley
Greenhorn
Posts: 27
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you all, we are using ActionForms (Struts) to back all the forms. I am quite sure I can implement the listener interface to catch the notify().
[ May 27, 2005: Message edited by: Christopher McCauley ]
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic