• Post Reply Bookmark Topic Watch Topic
  • New Topic

Idempotency not understood

 
Nitin Bhardwaj
Ranch Hand
Posts: 72
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi 2 interested ones !!
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 ]
 
Joe Harry
Ranch Hand
Posts: 10128
3
Eclipse IDE Mac PPC Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This is a very simple concept with respect to the HTTP methods! Non-idempotent means affect something. When you do a post request, you are actually changing something on the server. But this does not happen with GET. GET is for getting things. You just get the resource what you need. But with a POST, you post something on the resource you requested. Hope this small explanation helps!
 
Nitin Bhardwaj
Ranch Hand
Posts: 72
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Jothi, thanks for your prompt reply. But do you mean that we can't use parameters passed through GET request to do an update in the DB?
What does "change anything on the server" actually means?
What type of a change?
Please clarify.
Thanks again !!
Nitin
 
mohan kumar r
Ranch Hand
Posts: 38
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
confused with getting the things with GET and posting the things with POST,right?
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'
 
Joe Harry
Ranch Hand
Posts: 10128
3
Eclipse IDE Mac PPC Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Nitin,

Just remember this GET is for getting things and POST is for posting things on the resouce you want to deal with. Google out this and you will get ample number of resources for this.
 
Nitin Bhardwaj
Ranch Hand
Posts: 72
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hey Mohan I know the answers to those questions. But I am confused in the particular topic that I have posted. Does that "idempotency of GET/POST" has something to do with response returned by server to web-browser or it has to do something with repeated update on server when we click "submit" button more than once on the form?
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.
Thanks !!
 
Joe Harry
Ranch Hand
Posts: 10128
3
Eclipse IDE Mac PPC Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Nitin,

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!
 
Anonymous
Ranch Hand
Posts: 18944
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

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....
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!