Ankit Kumar
Ankit Kumar

Reputation: 403

After every "Refresh" duplicate record created in JSP

I am using JSP as view and form submitting and Servlet as controller(Bussiness Logic) and Hibernate as DAO. whenever i create a new record then control redirected to listing page. and after every refresh duplicate data is created in DB.

I googled a lot but not got any sutisfactory solution.

Upvotes: 0

Views: 1534

Answers (1)

JB Nizet
JB Nizet

Reputation: 692231

You didn't show any code, but I can guess two problems:

  1. You're using GET to post a form which creates something in the database. You should be using POST. If you did that, you would at least get a warning from the browser when refreshing the page
  2. You don't redirect to the list page, but you forward to it. So when you refresh, the form is resubmitted and the object is recreated. Use the post-redirect-get pattern to solve this issue.

Upvotes: 1

Related Questions