4

I have one jsp page and after filling that page it goes to another report page which is readonly. On click submit on first form, it goes to second report page and saved data into database. I have back button on report second form ,or i refresh page Report form it save a copy of same fields in database.

What am I possibly doing wrong here ?

Shravan
  • 540
  • 6
  • 24
VIvek
  • 81
  • 1
  • 3

1 Answers1

4

There a number of ways around this problem

Session Token Use a session token to determine if the form that causes the intial submission has already been processed.

Redirect Use a redirect and not directly forward to the view from the servlet that performed the operation that you don't want to duplicate.

For example: let's say that after you insert the row, you want to display a page that shows the entity represented by that row. In your insertion servlet you would perform the SQL insert operation, but then you would NOT directly foward to the display page. You would redirect to a servlet that would obtain the result of the insertion and then that servlet forwards to the display page. That way, upon a refresh, all that happens is that the servlet re-obtains the record and displays it. No multiple insertions can occur.

Shravan
  • 540
  • 6
  • 24