Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

What is the meaning of idempotent?

 
avseq anthoy
Ranch Hand
Posts: 106
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I read page 112 to page 116 of Head First Servlets and JSP .
See a word "idempotent",but I can't understand its meaning after reading its story and explanation.
Can somebody explain the meaning of idempotent,and why the story says that the servlet does not send an obvious response?

thx!
 
samdeep aarzoo
Ranch Hand
Posts: 160
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
idempotent means u can do the same thing again and again
without any side effect
being idempotent is good
now look an example
take a shopping cart example
suppose u want to buy a book from amzon.com
u put that book in shopping cart electronically
and u have given ur bank account info earlier.
on checkout server debits from ur account
and servlet will update the database.
now think suddenly ur computer hang for 1 min
and after 1 min u didnt find any acknowledgment page
than u will click again .to
confirm ur request of book.
and wicked program again debit from ur account,
so this is the side effect.???
u want ur single request of book should
be taken seprately
get is idempotent
and post is not idempotent
hope it helps
 
Michael Ernest
High Plains Drifter
Sheriff
Posts: 7292
Netbeans IDE VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If a web operation is idempotent, as GET is supposed to be, then using it multiple times should achieve the same result. That is, the act of getting a page should itself not change the behavior of the GET operation.

The term "side effects" means to exclude the use of timestamps, hit counters, or other intended changes to page content as a violation of idempotency.
 
MI Mohammed
Ranch Hand
Posts: 146
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If i may add, been idempotent has to do with a state.
whether it changes something on the server or not.
If it changes the state of eg, date on a server.
Just put this at the back of your mind, idempotent has
to do with server side resorces.
The PUT method is not idempotent before a second requst
is checked before alteration. But Get and other just keep
altering the state of the data like soldier under command
with questioning the orders

Hope it's help.

SCJA 1.0 SCJP 1.4
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic