JavaRanch Home    
 
This page:         last edited 10 November 2009         What's Changed?         Edit

Double Submit Problem   

Double Submit problem:

Two most frequently used HTTP request methods are GET and POST. GET method retrieves resource from a web server. Resource is identified by base location and optional query parameters. Generally, parameters of GET request are used to narrow the result and do not change server state. The same GET request can be sent to the server as many times as needed.

On the contrary, parameters of POST request usually contain input data, which can change state of server application. Same data submitted twice may produce unwanted results, like double withdrawal from a bank account or storing two identical items in a shopping cart of an online store. Submission of the same data more than once in a POST request is undesirable and got its own name: Double Submit problem.

It can happen when clicking "Reload" on a page that was generated by a POST, or when clicking "Back" takes you to a page that was generated by POST. In both cases the browser will generally issue a warning, but from that it's not clear whether it will or will not have bad consequences. So it's better to avoid the situation entirely. Another way to try to avoid double submits is to set a cookie on the first submit, and then issue a warning if a cookie exists if another submit is attempted. This, too, isn't infallible.

Micheal Jouravlev discussed the similar issue in his article Redirect After Post. The link is given below:

http://theserverside.com/articles/article.tss?l=RedirectAfterPost

Bear Bibeault writes about the same issue in this JavaRanch Journal article

Also see PostRedirectGet


JavaRanchContact us — Copyright © 1998-2014 Paul Wheaton