Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Life of Idempotency

 
Yogendra Joshi
Ranch Hand
Posts: 213
  • Mark post as helpful
  • send pies
  • 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.
 
William Brogden
Author and all-around good cowpoke
Rancher
Posts: 13058
6
  • Mark post as helpful
  • send pies
  • 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
  • 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
  • Quote
  • Report post to moderator
Hi,

Can anyone please help me on this?

Thanks in advance.
Yogendra Joshi
 
Sebastian Janisch
Ranch Hand
Posts: 1183
  • Mark post as helpful
  • send pies
  • 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.
 
Don't get me started about those stupid light bulbs.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic