• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Dealing with postdata, re-submits and dupplicate entries.

 
Karthik Muthukumaraswamy
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 948
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
"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
Pie
Posts: 64993
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 ]
 
Dom Lassy
Ranch Hand
Posts: 181
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Use tokens.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic