• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

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

 
sura watthana
Ranch Hand
Posts: 77
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 40
Google App Engine Netbeans IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What do you think about blocking such requests from the client side ? Say , you disable the button on user click.
 
Piotr Nowicki
Ranch Hand
Posts: 611
1
IntelliJ IDE Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic