Win a copy of Think Java: How to Think Like a Computer Scientist this week in the Java in General forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Double Submission

 
James Lye
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I'm trying to prevent double submission of a html form.
I've implemented on the blocking of double clicks on the client end using javascript. Somehow the 2nd submit manages to go through and the Post request is sent to the server. I'm ignoring this for the moment because I'm implementing the "Synchronizer token" on the server side to catch double submissions as well.

On the 1st submit, the request is processed since the token is valid. While the server is processing the 1st request, (I used a Thread.sleep(10000) to simulate a long transaction), the request is submitted a 2nd time. According to my codes, the request will not be processed as the token is not valid.

However after successful processing of the 1st request (Thread.sleep(10000) ends), my servlet which is supposed to forward to a JSP to display the results of the transaction, will throw a
java.io.IOException: There is no process to read data written to a pipe.

I read from IBM's technote that this message is thrown when the client pressed Refresh, Back or Stop, or close their browser after making the request, but before receiving the response back from the server.

In this case, none of the buttons were pressed. It was simply a 2nd click on the submit button before the 1st click had completed processing. Has anyone encountered this problem before? Or has anyone successfully implemented the prevention of double submissions? I've tried almost everything I've read from the forums but it doesn't seem to be working.
 
Stan James
(instanceof Sidekick)
Ranch Hand
Posts: 8791
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I think it's the same problem IBM described even though they didn't list doing another GET or POST as a possible cause. I can induce the problem in my WikiServer by doing very fast GETs. I have to tap-dance on the refresh button to get fast enough but you've got that 1 second sleep to simulate longer response time.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic