aspose file tools*
The moose likes Struts and the fly likes Dealing with postdata, re-submits and dupplicate entries. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Dealing with postdata, re-submits and dupplicate entries." Watch "Dealing with postdata, re-submits and dupplicate entries." New topic
Author

Dealing with postdata, re-submits and dupplicate entries.

Karthik Muthukumaraswamy
Greenhorn

Joined: Oct 30, 2006
Posts: 12
I am sure most of you had to deal with this issue at some point of their experience with Struts. :-)

I am developing a Struts based app. where the following situation occurs.
a) the user is displayed an entry form to create a purchase order.
b) he enters all the required data and submits the form (a call to 'submit_order.do' action mapping is made and an order is created in the database).
c) upon successful order creation, struts-config then does a action forward to display the list of all orders present in the system.

d) the URL on the address bar remains the same (.../submit_order.do) as struts does a forward and not a redirect. At this point when the user clicks the "reload" button in his browser, a message saying "the page you are trying to submit contains postdata.....clicking yes will resend data and the action will be repeated." is displayed. If he continues to do that, submit-order.do action is repeated and a duplicate entry is created.

I found this link : http://www.theserverside.com/news/thread.tss?thread_id=28366#136061
that talks about this and limitations of struts w.r.to this issue.

Anyone have more ideas on how to handle this situation?
Thank you.
Brent Sterling
Ranch Hand

Joined: Feb 08, 2006
Posts: 948
"Redirect After Post"...yep...I am pretty sure I have read through that thread. I pretty much always specify redirect="true" when I am forwarding to another action. If by limitations you are talking about the post titled "Not so simple" then no, this solution does not prevent multiple submissions but it does not make that problem any worse either.

- Brent
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61654
    
  67

I talk about the so-called PRG technique (Post-Redirect-Get) pattern in this article.

Even though I am not a fan of Struts, I can think of no reason that you cannot implement the concept of Task and Page Commands ("Actions" in Struts parlance) using Struts as the framework/Front Controller.
[ January 19, 2007: Message edited by: Bear Bibeault ]

[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Dom Lassy
Ranch Hand

Joined: May 05, 2006
Posts: 181
Use tokens.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Dealing with postdata, re-submits and dupplicate entries.