Is there a servlet-based strategy for preventing a user from submitting a form and then hitting refresh over and over again? I guess I should clarify, I don't necessarily need to prevent the user from doing this, but I would like the server to be able to recognize the duplicate submit so that I can handle it. Thanks
Thanks for the PRG link. However my doubt is as follows :
You talked about submitting the POST request and then redirecting to a view when the request is COMPLETED and then the problem is solved because even if the user hits refresh , its only the view which will be posted again and would not cause a non-idempotent request.
But the above condition has a BIG IF, what IF the ISP provider of the user doing an online transaction is slow and the user gets frustrated and clicks refresh BEFORE completing the initial request. What i mean is, the original request is still in process and user clicks refresh , so a new HTTP POST would be submitted and thereby withdrawing the customers bank account twice. How will PRG pattern be able to stop this ? or is this an another way for doing this ?
Regards Yogendra N Joshi.
Meri Zindagi Hain Tab Tak.. Jab Tak Tera Sahara.... Har Taraf Tu Hi Tu Hain SAI Tera Hi Hain Nazara.....
The postback functionality that you intend to achieve for avoiding duplicate submission can be achieved by combining the URL method and the request URL verification. The code representation can be found at http://www.paramountideas.com/node/11
Just wanted to clarify - the real solution to my problem was to use the PRG as Bear outlined in his article. In my previous post I had mentioned using the Struts2 Token Interceptor, but that did not solve the problem I had described in my initial post. The token interceptor solves the problem where the user resubmits during the processing of the previous submit. So the end solution to my initial problem was to redirect from one action to another which in turn changed the url and disallowed users from clicking the refresh button and inserting duplicate records.