aspose file tools*
The moose likes Struts and the fly likes auto-save from data when session times out Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "auto-save from data when session times out" Watch "auto-save from data when session times out" New topic
Author

auto-save from data when session times out

Teresa Lee
Greenhorn

Joined: Feb 01, 2008
Posts: 24
I am developing an application using Struts 2. I need to save form data to database automatically before session times out (like the user walks away ...). Anybody has any idea how I can do it, please?

Thanks.
David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

Save it when the form is submitted?
Tom Rispoli
Ranch Hand

Joined: Aug 29, 2008
Posts: 349
I use javascript to periodically submit request to keep my session alive for one of my screens. You could do something similar to automatically save after a time interval. Or display a message to your user letting them know that thier session is timing out.

There maybe be better ways, but that was what I came up with.
Teresa Lee
Greenhorn

Joined: Feb 01, 2008
Posts: 24
Originally posted by David Newton:
Save it when the form is submitted?


No. The situation is like this: the user is doing some data entry and he got an emergency call and he has to walk away immediately ( even has no time to hit the save button) and when he comes back like in 2 hours he doesn't want to login and start all over again. He just wants to login and go back to whereever he was at before he left.

Thanks for your prompt reply.
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18887
    
    8

So, save it when the form is submitted. You could wait until the session times out and then save it, but why wait? You didn't say why saving the data right away was unacceptable.

Edit: Let me put it this way. Suppose there was a network failure while the user was still working, and it took a couple of hours to repair that. Would you still have the same interest in having the user sign on and carry on from where he/she left off? If so, then you need to save the user's data as soon as it is submitted.
[ December 08, 2008: Message edited by: Paul Clapham ]
Teresa Lee
Greenhorn

Joined: Feb 01, 2008
Posts: 24
The goal is that I have to somehow save the user's work into database even without the user submitting the form. This is one of the user requirement. I am thinking to initiate an Ajax call to save the form data into database when I detect that there is no user activity on the page for a time interval. Do you think it's doable?
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18887
    
    8

Oh, I see. The point of the question is that there is no request yet.

Sure, sounds like that could be done via AJAX. But this is the Struts forum... maybe you should post this in the HTML and Javascript forum?
Teresa Lee
Greenhorn

Joined: Feb 01, 2008
Posts: 24
All right. I will try to see if it works first. Otherwise, I will do as you said to post my question somewhere else. Thanks.
Vidyasagar Guduru
Greenhorn

Joined: Apr 17, 2006
Posts: 26
I think there is a session timeout event listener available, you can explore that option whether it is usable.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: auto-save from data when session times out