I was reading HF Servlets & JSPs when I came to the topic "The story of the non-idempotent" request. I simply was unable to catch what the authors were trying to tell by these lines:
"An HTTP GET is just for getting things, and is not supposed to change anything on the server.So, a GET is, by definition idempotent.
POST is not idempotent- the data submitted in the body of a POST might be destined for the transaction that can't be reversed.
There are several different uses of the word \"idempotent\"; we're using it in the HTTP/servlet way to mean that the same request can be made twice with no negative consequences on the server. We don't use \"idempotent\" to mean that the same request always returns the same response, and we don't mean that a request has NO side effects." -- Pgs112-117
What is the meaning of all this?
Can anybody clear this concept with the help of examples which compares both GET and POST requests? Means in a single example what will happen if I use GET request and what will happen if I use POST request?
Thanks for showing interest in this problem !!
Please help !!
[ February 02, 2007: Message edited by: Bear Bibeault ]
you can use any one for both but find answers to below questions
-are you able to send/submit URL/data lareger than 1024 characters using GET?
-are you able to send binary data as java serialigable objects in GET
-did you see what is happening in browser address bar when submitted from a form with method='GET' and from a form with method='POST'
I mean i want the difference between GET and POST regarding "Idempotency" as discussed in "Head First Servlets and JSPs".
Please help in that regard.
Imagine you have resource A stored in a container(Tomcat) and you are doing a GET request on it and you are trying to change something with a GET request which won't have any effect. Meaning the change that you wanted to do on the resource didn't work and you get resource A unchanged. Now imagine you do a POST request for resource A and you try to change something on it. Once you do this, the change is made on the server resource A and the updated resource is returned to you.
Did you understand this??? See page 112, as there is a more detailed example on this page!
In any real-implementation, the servlet gets the request in service() method, and forwards to doGet() or doPost() based on the HTTP Request. actually there exist other methods, but who uses them?? rarely??
doGet, if the servlet supports HTTP GET requests
doPost, for HTTP POST requests
doPut, for HTTP PUT requests
doDelete, for HTTP DELETE requests
init and destroy, to manage resources that are held for the life of the servlet
getServletInfo, which the servlet uses to provide information about itself
Then 99.99999% of the time, the software designer forwards the request to a process_me() method from both doGet() and doPost()...
This means, doGet() might also change sth. on the server side, depending on how you handle it!
so ==>>> be careful all the time what you are doing....