• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
  • Liutauras Vilda
  • Campbell Ritchie
  • Tim Cooke
  • Bear Bibeault
  • Devaka Cooray
  • Jeanne Boyarsky
  • Knute Snortum
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Ganesh Patekar
  • Stephan van Hulst
  • Pete Letkeman
  • Carey Brown
  • Tim Holloway
  • Ron McLeod
  • Vijitha Kumara

Database replecation from Jsp  RSS feed

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
author & internet detective
Posts: 38571
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!