• 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

Life of Idempotency

 
Ranch Hand
Posts: 213
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Howdy Ranchers,

I was reading K&B Head First and i came across issue of Non-Idempotent request. I want to know how the problem can be stopped. I mean, Its obvious that the user of the site would feel to click SUBMIT button more then once and if it really debits then its a BOMB for the developer.

Since, every request is given a new request / response thread, how would there be a way to identify multiple same requests from the same client that too erroneous just because the net connection was slow in responding or probably due to very bad code which takes time in responding to user request ?

This issue might also occur due to temporary link breakdown and infamous "Page cannot be found" and then user pressing the back button to submit the same request again ? I am really looking forward to know this ?

Thanks in advance,
Yogendra N Joshi.
 
Author and all-around good cowpoke
Posts: 13078
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The problem of multiple requests shows why you may want to synchronize on the Session object. The first request to grab the session object can use it to record the current state of the application. When subsequent requests can obtain access they will see that the state has already been changed.

Bill
 
Yogendra Joshi
Ranch Hand
Posts: 213
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Bill,

Thanks for your response. Great to know the synchronization part, can you give me more details on the implementation ?

Regards,
Yogendra
 
Yogendra Joshi
Ranch Hand
Posts: 213
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

Can anyone please help me on this?

Thanks in advance.
Yogendra Joshi
 
Ranch Hand
Posts: 1183
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Well, synchronize on the session object and before you update any data check if it has not been updated before.




Another client side way to prevent a user from clicking the submit button more than once is disabling it immediately after the click using javascript.
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic