• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

How to stop user entering a record twice?

 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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 ]
 
Ranch Hand
Posts: 74
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Ranch Hand
Posts: 74
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Ranch Hand
Posts: 783
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
reply
    Bookmark Topic Watch Topic
  • New Topic