Submits again

In order to add some data I forward my page to a servlet which calls a bean to add new entry and finally servlet forwards to a new page. If at that  page user refreshes page then a duplicate entry is entered in the database. What to do to avoid it
rea_19Asked:
Who is Participating?
 
thomas908Commented:
After processing, use response.sendRedirect() to forward to the next  page.
This load the page from a new request, and refreshing the page will only reload the page without resubmitting the data.
0
 
TimYatesCommented:
Thomas is correct...  Just to clarify his point (please don't accept this comment as an answer), you do:

  Form.jsp     ---POST--->    Processing.jsp    ---REDIRECT--->   Thanks.jsp

Then the user can't go "back" to the Processing.jsp, so can't resubmit thir form :-)
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.