my dog learned polymorphism*
The moose likes Struts and the fly likes Refreshing a page calls previous action Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Refreshing a page calls previous action" Watch "Refreshing a page calls previous action" New topic
Author

Refreshing a page calls previous action

Clarence Dyho
Greenhorn

Joined: Sep 17, 2001
Posts: 23
Hello,

I have a page where a user can edit his contact details. When the user clicks on the update button on that form, the update action writes the info to the database and forwards the user to a success page.

My problem is that when the user refreshes the sucess page (F5 or the refresh icon in IE), the update action class gets called again. The same thing happens when the user presses the back button the press the forward button again.

Is there a way I can code the action (or the JSP page) to clear attributes or forwards? Thank you.


regards,
Clarence
Marc Peabody
pie sneak
Sheriff

Joined: Feb 05, 2003
Posts: 4727

Use tokens. The key is to save a new token upon each submission. This will prevent a double submission.


A good workman is known by his tools.
Clarence Dyho
Greenhorn

Joined: Sep 17, 2001
Posts: 23
Thank you Marc. It worked! And Struts has built in classes to handle it too!

Thanks so much,
Clarence
Srilakshmi Vara
Ranch Hand

Joined: Jul 21, 2004
Posts: 169
Hey Marc,

Can you please explain a little about the token on submission, i got the same problem

Thanks in Advance
Srilakshmi
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Refreshing a page calls previous action
 
Similar Threads
what does redirect attribute of action forward do when set to false
submit form problem
To put in the session or in the request ?
servlet/jsp question
DispatchAction problem