aspose file tools*
The moose likes Servlets and the fly likes How to Handle timeout to save user input Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "How to Handle timeout to save user input" Watch "How to Handle timeout to save user input" New topic
Author

How to Handle timeout to save user input

Christopher McCauley
Greenhorn

Joined: Jan 03, 2005
Posts: 27
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 ]

JCM<br />good at cookin'
Adeel Ansari
Ranch Hand

Joined: Aug 15, 2004
Posts: 2874
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

Joined: Sep 11, 2002
Posts: 167
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?


Alco-Haul: We move spirits.
Demented Deliberations of a Dilettante
William Brogden
Author and all-around good cowpoke
Rancher

Joined: Mar 22, 2000
Posts: 12671
    
    5
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


Java Resources at www.wbrogden.com
Adeel Ansari
Ranch Hand

Joined: Aug 15, 2004
Posts: 2874
Or simply make it, session-timeout, -1.
William Brogden
Author and all-around good cowpoke
Rancher

Joined: Mar 22, 2000
Posts: 12671
    
    5
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

Joined: Jan 03, 2005
Posts: 27
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 ]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: How to Handle timeout to save user input
 
Similar Threads
Form Tokens
session destroyed navigational issue
Conditional Validation Determined By Which Button Was Clicked
JavaScript that can stop processing
Preventing the submission of a jsp/html page on users relogging in after timeout