web-applicationsweb-frameworksdouble-submit-prevention

Solving the Double Submission Issue


I would like to see how Web Developers avoid the double submission problem. So basically my understanding of the problem is as follows:

Double submission occurs when an impatient user submits a form multiple times, causing issues. This problem can be fixed by JavaScript (specifically jQuery scripts) that disable the submit button once the form has been submitted - a weakness of this is if clients have JavaScript disabled.

There is also server side methods of detection.

So my questions are:

How do people overcome double submission? What is a real life example of a problem caused by double submits? Do any Web Application Frameworks have double submission tools built in?


Solution

  • If you are working with java server side scripting and also using struts 2 then you refer this link which talks about on using token .

    http://www.xinotes.org/notes/note/369/

    A token should be generated and kept in session for the initial page render, when the request is submitted along with the token for the first time , in struts action run a thread with thread name as the token id and run the logic whatever the client has requested for , when client submit again the same request, check whether the thread is still running(thread.getcurrentthread().interrupted) if still running then send a client redirect 503.

    Please look at the ExecuteAndWaitInterceptor of struts 2code, the logic of this combined with token will help out fast click