Win a copy of Cross-Platform Desktop Applications: Using Node, Electron, and NW.js this week in the JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Synchronizer Token example  RSS feed

 
adeeb alexander
Ranch Hand
Posts: 268
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi.
Someone please please provide a simple Synchronizer Token example to avoid duplicate form submission. I have searched a lot, only got example which uses some or the other Framework. I need the example in to implement only in servlet ie. without using any framework. Please help me out.




Thanks.
Adeeb
 
Jeanne Boyarsky
author & internet detective
Marshal
Posts: 37180
515
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
There are a few approaches. The easiest is to set an attribute in the session when you display the form and remove it when you receive the form. If the attribute isn't there to delete, it is a duplicate submission.

Two related patterns/techniques:
1) Use JavaScript to disable the form button so the user doesn't click twice. (useful if users have dialup)
2) Use Post Redirect Get pattern so user hitting refresh doesn't submit the form again
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!