Hi.
Just trying to learn about jsp and servlets. I guess this is only
remotely java as servlets are frequently written in java.
I see this at: http://www.w3.org/Protocols/rfc2616/rfc2616-sec9.html
9.1.2 Idempotent Methods
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.
So it sounds like post isn't idempotent. But in my head first servelts
and jsp book, on page 114 at the bottom it says:
"POST is considered idempotent by the HTTP 1.1 spec."
So I'm confused. Is it or is it not idempotent (post)? and what the
heck does it mean in laymans language (I know it means supposedly that
the operation/request returns the same result everytime, so it
'sounds' like post isn't necessarily idempotent)
thanks for the clarity
Jeff Kish - 12 Jul 2006 03:12 GMT
>Hi.
>
[quoted text clipped - 21 lines]
>
>thanks for the clarity
I guess it (post) is not idempotent. On the following pages in the
book it gets quite clear on that point. Sorry for the bandwidth use,
but it is confusing when two opposite things are said, though the book
seems quite good otherwise.
Chris Uppal - 12 Jul 2006 09:58 GMT
> So I'm confused. Is it or is it not idempotent (post)? and what the
> heck does it mean in laymans language (I know it means supposedly that
> the operation/request returns the same result everytime, so it
> 'sounds' like post isn't necessarily idempotent)
The most important thing about idempotent operations is that it's OK to do it a
second time (or third...) if you are not sure whether it worked the first time.
Example of an idempotent operation:
x = 33;
Example of a non-idempotent operation:
x += 33;
So, a web client can safely resend a PUT request automatically if there seems
to be a problem with the Net, but it must not do so automatically for a POST,
since that might, for instance, end up with the user buying several oil tankers
instead of just one.
-- chris
Thomas Hawtin - 12 Jul 2006 15:54 GMT
> I see this at: http://www.w3.org/Protocols/rfc2616/rfc2616-sec9.html
> [...]
> So I'm confused. Is it or is it not idempotent (post)? and what the
> heck does it mean in laymans language (I know it means supposedly that
> the operation/request returns the same result everytime, so it
> 'sounds' like post isn't necessarily idempotent)
It's in the errata.
{114,116} Answer to Sharpen your pencil at bottom of page 114;
"POST is considered idempotent by the HTTP 1.1 spec."
should be:
"POST is not considered idempotent by the HTTP 1.1 spec."
http://www.oreilly.com/catalog/headservletsjsp/errata/headservletsjsp.confirmed
Idempotent means that only the first post may (but need not) alter
state. So you could have a URL representing a particular game of chess,
and add to that a move number and move. Technically that move could be
submitted with a GET, having the effect that that move is made permanent
and the next move must have the next move number and a valid move given
the previous moves.
However, various bits of software may well decide to load linked pages
into a cache without user intervention. Therefore it's generally best to
keep it simple, using GET only for side effect free operations and POST
for state change operations. A useful technique is to respond to a POST
with a redirect, meaning that the resulting page can be reloaded with
GET multiple times.
Tom Hawtin

Signature
Unemployed English Java programmer
http://jroller.com/page/tackline/
Jeff Kish - 13 Jul 2006 04:15 GMT
>> I see this at: http://www.w3.org/Protocols/rfc2616/rfc2616-sec9.html
>> [...]
[quoted text clipped - 27 lines]
>
>Tom Hawtin
Thanks, especially for the errata pointer. I've printed it out and am
penciling in corrections.
Good Luck finding a job. Are things slow in South England?
Regards