I have an application
user clicks submit
data sent to database
user redirected to another page.
The problem is, it takes about 5 seconds from the time the user clicks submit to the time they're redirected to the other page. And in this 5 seconds, users sometimes double click on Submit, so the data is submitted twice! I want my servlet to only accept one submit within say 5 seconds in a Session. How can I do this?
Idempotency is the design pattern. For some actions, its trivial. You simply return the same result as you would have returned the first time it was executed. So if the command is "delete record for James Byars" you return "all records for James Byars deleted"
If it was "create James Byars record" then you have problems. So change the definition to "make sure that there is a James Byars record" and then its easy.
The hard one is "add one to James Byars's balance"
I was wondering if you could simply display a message saying that the page is being loaded please wait... or something of this sort.
When I go internet shopping, I see such messages being displayed at many payment gateways. They ask the user to submit only once as clicking the button twice would result in duplicate transactions.
One more suggestion - not sure if it would be a good idea, but I think that instead of disabling the submit button, you can add a Load Mask on the entire page while the redirect takes place. Thus the user won't be confused and would wait patiently for the redirect. Just an idea...
SCJP 1.5 | SCWCD 5 | SCJP 6.0
[url]http://a2zjava.webs.com[/url] - Online training for Java/JSPs and Servlets/SCJP/SCWCD
I’ve looked at a lot of different solutions, and in my humble opinion Aspose is the way to go. Here’s the link: http://aspose.com
subject: how can I stop the submit being processed twice?