• 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

How does post() method serve the purpose of non-idempotence?

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

I have a doubt regarding idempotence. I read in head-first servlets and jsp that post() methods are non-idempotent as per specification.
Say, I have a link which calls a post() method that updates some thing in database. Does it mean that if I click twice or thrice, it will invoke only once.

How post() methods server the purpose of non-idempotence.

Thanks in Advance.
Loganathan. K
 
Bartender
Posts: 3648
16
Android Mac OS X Firefox Browser Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Loganathan Karunakaran wrote:
Say, I have a link which calls a post() method that updates some thing in database. Does it mean that if I click twice or thrice, it will invoke only once.



Idempotence means that the resulting action IS the same no matter how many times it is triggered.

Using the example of INSERT a record to database, when POST is triggered twice, 2 records will be inserted to database. Therefore, POST is considered non-idempotent.

 
Rancher
Posts: 43081
77
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Loganathan, you have it backwards: the servlet engine doesn't enforce anything, it merely assumes that a GET will be idempotent, and a POST won't. It is the developer's responsibility to ensure that what the doGet method does is, in fact, idempotent.
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic