• 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

JSP Button Problem

 
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi, i'm experiencing a problem with JSP Buttons.
The scenario is as follows.

My "Submit" button is linked directly to the DB and whenever that button is clicked, an entry is recorded. Each entry is meant to be unique. However, during testing, i realized that if you double click on the button, 2 similar entries will be added into the database. The only difference would be the time of entry, which would vary by about 1 second or so.

My question is, is there a way to control this problem?

The codes are as follows

INPUT TYPE=submit VALUE='Yes' style="width:80" name=cmdYes
INPUT TYPE=button VALUE='No' style="width:80" name=cmdNo
Hopefully someone can help me in this situation

Best regards
weugene
 
Ranch Hand
Posts: 724
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Maybe you could use javascript and after clicking the button, disable the button.
Or you could use some constraint like UNIQUE in the database.
 
Ranch Hand
Posts: 2874
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
first of all avoid duplicate entries in your table, use primary key.

about submit button. you can try to a simple "button" instead of "submit". and then onClick event submit your form through javascript. not sure it would help you or not. just try it out.
 
author
Posts: 15385
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
JavaScript should not be your answer, you should deal with it on the server side!

Check to see if the record exists before adding the information to the database.

Eric
 
Adeel Ansari
Ranch Hand
Posts: 2874
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Actually, if dont want to request the server for this kind of thing. I really dont want the double click to work then what I can do?

And ofcourse never rely on client side only. we should do our every type of validations on server-side. And I think if we have our table well defined with constraints like, PK, UK; as I said. then all we have to handle is the thrown exception.

Thanx.
 
Ranch Hand
Posts: 645
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Actually, i dont want to request the server for this kind of thing



And ofcourse never rely on client side only



Is there 3rd option avilable on Earth ??

If you dont want to alow double click then use javascript.
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic