I am working on a web application (J2EE) and I would like to know the options that are available for handling a double post from the browser.
The solutions that I have seen and used in the past are all client-side:
- Disable the submit button as soon as the user clicks it.
- Follow a POST-Redirect-GET pattern to prevent POSTs when the user clicks the back button.
- Handle the onSubmit event of the form and keep track of the submission status with JavaScript.
I would prefer to implement a server side solution if possible. Are there any better approaches than the ones I have mentioned above, or are client-side solutions best?
I'd use a timestamp and compare values with your server side code. If two timestamps are close enough and have the same IP address, ignore the second form submission.