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

Problem with updating the Jsp page .  RSS feed

 
smyle khanna
Ranch Hand
Posts: 54
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi,
i have written a program in jsp with jdbc connection.it contains certain fields like name,address,contactno etc.On clickin the submit button it gets stored in the database.
But if i refresh tht page after this then the previous details entered get stored again in the database.
how 2 i reset the setting of all these fields,
thanx
Smyle.
 
Ram Mohan
Ranch Hand
Posts: 44
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i guess u'll have to use sessions....
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 66203
151
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This is a classic problem. When you refresh the page, the post operation that triggered the DB operation is resubmitted.
Even though Ram's reply wasn't particularly helpful, a common technique for dealing with this problem does use the session. Basically you generate a unique token when you create the original posting form, placing it in a hidden field and placing it on the session. When the form is submitted, you compare the hidden token with the session token and remove the session token. That way when the form is submitted a second time, the session token does not exist and you can avoid the second DB operation.
bear
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!