aspose file tools*
The moose likes Web Component Certification (SCWCD/OCPJWCD) and the fly likes Is there a way to make a java web app to deal with multiple duplicate requests sent by users? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Web Component Certification (SCWCD/OCPJWCD)
Bookmark "Is there a way to make a java web app to deal with multiple duplicate requests sent by users?" Watch "Is there a way to make a java web app to deal with multiple duplicate requests sent by users?" New topic
Author

Is there a way to make a java web app to deal with multiple duplicate requests sent by users?

sura watthana
Ranch Hand

Joined: Sep 13, 2004
Posts: 77
Scenario is: let's say a user submits a request to purchase a book from an online book store. response was slow due to ... .
the user thought the web app didn't get the request. the user clicks submit button again. now the web app receives the exact same
request twice.

is there a way to make a java web app to deal with multiple duplicate requests sent by user?
in other word, how to make a java web app idempotent?
Srinath Gamage
Ranch Hand

Joined: Jun 19, 2008
Posts: 40

What do you think about blocking such requests from the client side ? Say , you disable the button on user click.

SCJP & SCMAD
http://srinathbugz.blogspot.com/
Piotr Nowicki
Ranch Hand

Joined: Jul 13, 2010
Posts: 610

It's an universal problem - not only related to the Java. If you are not using sessions or HTTPS, the web server (HTTP) is stateless, so it doesn't have a clue if you executed the request before or not.

You can implement your own mechanism based on sessions to prevent such actions. I.e. you could put some attribute into the user's session which will mean that the user cannot execute the same action within, let's say, 2 minutes.


OCP Java SE 6 Programmer, OCM Java SE 6 Developer, OCE Java EE 6 JSPSD, OCE Java EE 6 EJBD, OCE Java EE 6 JPAD, Spring 3.0 Core Professional.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Is there a way to make a java web app to deal with multiple duplicate requests sent by users?