Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How to stop user entering a record twice?

 
R Chirag
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all,

I don't know whether this topic is related to servlet or jdbc. But I'm posting it here.
I'm developing an application and I want to stop user entering a record twice by pressing "Refresh" and "Back" button. Is there any Listner and/or Event to refrain user entering a record twice? [I found "Synchronizer Token pattern" but I know very little about design patterns.]

Hoping 4 ur benign reply,
Thanks in advance
Chirag.

[ August 17, 2005: Message edited by: Chirag ]
[ August 17, 2005: Message edited by: Chirag ]
 
Ritesh Agrawal
Ranch Hand
Posts: 74
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Chirag,

Could you be please more specific on your requirement. I believe you have something like this.

--A Web Page containing user input form.
--On submit the form transfers the input data to server and displays a new page.
--User clicks Back or refresh and gets the input form again.
Now it seems you don't want the third step to happen. If I understand it correctly then, I can suggest two things that you need to do:

1st: It appears that your form is being displayed by a servlet and after form submission, the same servlet uses RequestDispatcher to display the confirmation or another page. So you can make the first page to be displayed by the servlet to be something else, which contains a link to the Form page. The user when clicks this link, use RequestDispatcher to open the Form page. Thus, when user clicks Refresh, always the first page will be displayed and not the Form Page. From the first page the user can go to Form Page which I think should be OK.

2nd: Back button functionality can be prevented by doing a work around. You may not allow two successful submit from the same session programatically.

If some one else can provide better or different solution I would be happy to know about that.
 
Baiju Varugese
Ranch Hand
Posts: 74
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Synchronized tocken is
while redirecting/loading the user form generate a token/random number and store it in the user session and also in a hidden field in the form. on submit of the form check the session token with the hidden field value if it matches do you operation else forward it to some other page, after validate the token update the session token with the new value, this will prevent the user to submit the form twise
 
Paul Bourdeaux
Ranch Hand
Posts: 783
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Chirag,

Welcome to the ranch. Baiju Varugese was right on with the synchronized token. Also, you will need to change your name to match the
JavaRanch Naming Policy before yuou attract the attention of a bartender.
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64833
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
"Chirag",

There aren't many rules that you need to worry about here on the Ranch, but one that we take very seriously regards the use of proper names. Please take a look at the JavaRanch Naming Policy and adjust your display name to match it.

In particular, your display name must be a first and a last name separated by a space character, and must not be obviously fictitious.

Thanks!
bear
Forum Bartender
 
Don't get me started about those stupid light bulbs.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic