Is there any way for the servlet to distinguish between a request from a button click(form submit) versus a request from the "Refresh" or "Reload" button of the browser? Thing is, we are trying to disallow/(not process) requests from the latter.
Just looking for better alternatives to loading the page in a new window with no browser buttons.
Any advice is very much appreciated! Thanks in advance!
Take a look at struts framework. It has the feature to avoid resubmitting the form on refresh.
You can do this by issuing an incremental formID to the form. When a form is submitted, store the formID in the user session. When a form is submitted check if the ID is less than or equal to the ID you alredy have in the user session, that way you can tell if a user has alredy submitted the form onece
Maybe I have a lack of basic JSP/Servlet knowledge but:
If I use a counter ID to find out if a form has been already submitted. what about this scenario:
User A loads the JSP with the form.
User B loads the JSP with the form, too.
User A submits the form. The controller receives it and everything is OK incrementing the counter.
User B now submits the form and the controller says: 'No, your counter is not valid.' (Because the submitted counter is lower than the controller's counter).
Where is my logical error?