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 ]
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.
Ritesh<br /> <br />SCJP 1.4<br />IBM Test 340<br />IBM AIX V4.0 Certified Professional<br /> <br />Right actions for the future are the best apologies for wrong ones in the past.<br />- Tyron Edwards
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
Measure twice cut once carpenter theory <br /> <br />Baiju <br />SCJCP, SCBCD, IBM-486, IBM-484, SCEA Part I
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.
“Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning.” - Rich Cook