aspose file tools*
The moose likes Web Component Certification (SCWCD/OCPJWCD) and the fly likes Why PUT is idempotent ? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Web Component Certification (SCWCD/OCPJWCD)
Bookmark "Why PUT is idempotent ?" Watch "Why PUT is idempotent ?" New topic
Author

Why PUT is idempotent ?

Edisandro Bessa
Ranch Hand

Joined: Jan 19, 2006
Posts: 584
Hi guys,

In HFSJ book the authors say that GET, HEADER and PUT are idempotent.

I'm really aware regarding the GET and HEAD methods but why PUT is also idempotent ?

I think I must first understand what's the PUT purpose.

As per my understanding, PUT is used to literally put some file on the server. Is it correct ?

If PUT is idempotent, is DELETE as well ?

Could you please explain which are idempotent ?

GET : Idempotent
POST : Non-Idempotent
HEAD : Idempotent
PUT : Idempotent. Why ???
DELETE : I really don't know. I think it's not idempotent. Please explain.
TRACE : Idempotent
OPTIONS : Idempotent
CONNECT : I really don't know. I think it's idempotent. Please explain.

TIA,
Edisandro Bessa.
[ October 05, 2006: Message edited by: Edisandro Bessa ]

"If someone asks you to do something you don't know how to, don't tell I don't know, tell I can learn instead." - Myself
Holger Kraus
Greenhorn

Joined: Feb 19, 2003
Posts: 3
Hi Edisandro,

I think the mathematical definition of idempotence from wikipedia helps:
"A unary operation (i.e., a function), is idempotent if, whenever it is applied twice to any element, it gives the same result as if it were applied once."

If you put a file to the server, the file will only be there once, even if you perform the PUT more than once. => idempotent

Its the same with DELETE. If you have deleted a file on the server, a second delete will have the same result: Theres is no file with the name of the deleted one. => idempotent

If you send an order to an online-shop by using POST, a second POST will imply a second order, so the result is not the same. So the result is not the same. => not idempotent

All other methods are idempotent, too.

I hope, that helps.

Best regards

Holger


--<br />SCJP<br />SCJD<br />SCWCD
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Why PUT is idempotent ?