wood burning stoves 2.0*
The moose likes Servlets and the fly likes Preventing doubleclicks Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "Preventing doubleclicks" Watch "Preventing doubleclicks" New topic
Author

Preventing doubleclicks

Mila
Ranch Hand

Joined: Feb 14, 2002
Posts: 31
Hi,
I have a problem in Web Application (JSP/Servlet)
considering double clicks & multiple submits of the same form. I do software to Financial sector and especially application's Jsp-forms where moneytransfer is submitted by a customer I MUST prevent double clicks & multiple submits of the form. I know that javascript code can easily prevent this, but our application must also support customers that do not have javascript enabled in their browser. I need some code to Java server side, but what kind of approach would help? I tried to use a timestamp in a hidden field of the JSP page and compared that in controller servlet (it was saved to session object in first submit) and then compared them and decide if submit should be done or not. But I did not get any good results. Also disabling a backbutton of the browser in servlet side is painfull, don't know how to do it properly.
Have anyone resolved these problems? I thing that there are so much banking & financial software around the world that this could be resolved with some kind of pattern. So, if anyone knows any pattern and especially sample code to handle these problems I would be very pleased to get it.
Thank you!
Mike
Dave Vick
Ranch Hand

Joined: May 10, 2001
Posts: 3244
Mike
This mght be better suited to the HTML/Javascript forum.

Dave
ersin eser
Ranch Hand

Joined: Feb 22, 2001
Posts: 1072
Hi,
Read Chapter 7 of Advanced JSP from David M. Geary it is about trapping form resubmissions with or without MVC !
Mila
Ranch Hand

Joined: Feb 14, 2002
Posts: 31
OK,
First I must say that only javascript solutions are not the proper way to handle re-submissions in the financial softwares where money transfers etc. have important roles, that was also
mentioned somewhere in Sun's seminar documentation.
I will check that Advanced JSP from David M. Geary, thanks!
I also noticed that Struts has a "Action Token"
mechanism to handle doubleclicks etc. It uses also
session object, not javascript.
Maybe a look at they source code would help to understand how to handle this kind of problems.
BTW: Quite many important Internet softwares may have lack of this kind of property...
ersin eser
Ranch Hand

Joined: Feb 22, 2001
Posts: 1072
Don't buy it , it is kinda out dated , just stop by the local bookstore to read it quickly, he talks about using tokens too.
[ February 28, 2002: Message edited by: ersin eser ]
Matthew Phillips
Ranch Hand

Joined: Mar 09, 2001
Posts: 2676
Mike L,
Javaranch has a naming policy. Please change your display name to comply with that policy so that you may continue to post here. Thanks.


Matthew Phillips
Matthew Phillips
Ranch Hand

Joined: Mar 09, 2001
Posts: 2676
Originally posted by Mike L:
OK,
BTW: Quite many important Internet softwares may have lack of this kind of property...

As a victim of software that does not handle double clicks properly I have to agree with you.
Thomas Mcfarrow
Ranch Hand

Joined: Jul 09, 2001
Posts: 137
I would try the following. (just an opinion)
Why don't you make a synchronized method that will set a flag in the session on form submission and return a boolean whether or not the session object existed.
In the doPost call this method. Depending on the return value send the appropriate response.
Mila
Ranch Hand

Joined: Feb 14, 2002
Posts: 31
Is my alias satisfying everyone???
But, back to business ;=) In JGuru there were also
people discussing this same multiple submits handling.
Topic in the following url might give some information and solution to this problem to people interested in it.
http://www.jguru.com/forums/view.jsp?EID=726218
Br
 
 
subject: Preventing doubleclicks
 
Similar Threads
prevent form double submit
Double Submission
cannot get javascript to prevent duplicated form submit
multiple form submission
Is my code running twice? JSP, java beans, db updates - strange happenings