Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Database replecation from Jsp  RSS feed

 
Sultan AlQahtani
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi all i am new member in this gerate site.

can any body help me in this problem.
i have project in jsp (dynamic creation for questions)which generate a web site and make rigisteration for user, which accepet his name, subject for the questions, number of questions that he want to cereate them and number of those questions.

the problem when the user access this web site and fill out the form and click submit he got the questions succefully but the problem is when the user click referish on the current page, the publisher got replication in the database.

method i used in the form is post
and my database is MySQL
 
Jeanne Boyarsky
author & internet detective
Sheriff
Posts: 37230
519
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sultan,
You need to code a technique to prevent the same request from being sumbmitted twice. A common approach uses a token in the session. When the user views the form to add data, you put a token (like a String) in the HttpSession. Then when the user presses submit you have your servlet/jsp check for the token's presence. If the token is there, you update the database and delete the token. If the token is not there, it is a duplicate request.

Another alternative is to use a database key to check for a duplicate submisssion. You could put a hidden field with the time in the form. Then when the form is submitted, see if that is the same value in the database.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!