you can think like if request is not modifying anything in your database(although server-side is more correct word) then it is idempotent.for example if you are firing select query.. definitely get is idempotent if you use it correctly..
post is non-idempotent as its purpose is to modify... [ July 24, 2007: Message edited by: raj malhotra ]
And it's not really about never making updates, but about making the same update every time. If a PUT sets shoe size to 8 every time you call it, it can still be idempotent. If it increments a counter every time, it isn't.
Methods can also have the property of "idempotence" in that (aside from error or expiration issues) the side-effects of N > 0 identical requests is the same as for a single request. The methods GET, HEAD, PUT and DELETE share this property. Also, the methods OPTIONS and TRACE SHOULD NOT have side effects, and so are inherently idempotent.
However, it is possible that a sequence of several requests is non- idempotent, even if all of the methods executed in that sequence are idempotent. (A sequence is idempotent if a single execution of the entire sequence always yields a result that is not changed by a reexecution of all, or part, of that sequence.) For example, a sequence is non-idempotent if its result depends on a value that is later modified in the same sequence.
A sequence that never has side effects is idempotent, by definition (provided that no concurrent operations are being executed on the same set of resources).
All this tells how HTTP protocols "should" work. There's nothing but convention to prevent the code we add to an application server from breaking all the rules.
One time we care about this is when working with unreliable messaging. Maybe we send an update and never get a confirmation reply, so we send another copy of the same update. If it's idempotent, the second update will do no harm. [ August 01, 2007: Message edited by: Stan James ]
A good question is never answered. It is not a bolt to be tightened into place but a seed to be planted and to bear more seed toward the hope of greening the landscape of the idea. John Ciardi
Originally posted by sunny dh: PUT - not impotent or unsafe (side effects on server) ask the server to put or modify data on server at particular uri
DELETE - not impotent or unsafe (side effects on server) delete the resource on server
To expand on what Stan said, not only should PUT and DELETE be implemented in an idempotent manner, but being safe and being idempotent are not the same concept. [ August 12, 2007: Message edited by: Ulf Dittmer ]
PUT - not impotent or unsafe (side effects on server)
ask the server to put or modify data on server at particular uri
However, on Pg. 114 of "Head First Servlets and JSP", it is written that GET, PUT, HEAD are idempotent (it must have been misspelled as impotent) according to HTTP spec 1.1.
So I guess except POST (which passes data to the server "to be processed") every other HTTP method is idempotent. However, we can have an non-idempotent implementation of doGet() method in our Servlet but that does not mean that the HTTP GET method is non-idempotent.