wood burning stoves 2.0*
The moose likes Web Component Certification (SCWCD/OCPJWCD) and the fly likes Idempotent request 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 "Idempotent request" Watch "Idempotent request" New topic
Author

Idempotent request

ragunath selvaraj
Greenhorn

Joined: Jan 09, 2007
Posts: 3
can any one explain abt the idempotent and non-idempotent request?

I cant understand the scenario explained in the Kathysieera jsp and servlets book ..page no is 109.
Deepak Jain
Ranch Hand

Joined: Aug 05, 2006
Posts: 637
Hey,
Let me also give it shot This will be my first post to SCWCD forum am gearing up for SCWCD, Behold

Idempotent: Multiple request to a servlet with same parameters must not have side effects on server.
Is it good to be idempotent: Yes.

GET: HTTP SPEC says that GET is idempotent. GET must be used to GET things from the server. Although it can be used to update data on the server. Ideally it should be used to get things from the server. Since this is what GET is supposed to be used GET SAME THINGS again and again from server will never cause any side effects on the server. And hence GET is considered to be idempotent.

POST: HTTP SPEC says that POST is not idempotent. POST must be used when you want to update the server and hence it can become non-idempotent that is multple same requests can cause side effects on the server.

Now coming to the side effect: In HF book when the client makes the second request considering the first request did not reach the server, the container will simply think that the client wants to buy the same book again and will cause the transaction to happen, But the client did not want to buy the same book again, the client made the request assuming that the first request did not reach the server. So now there is problem. And these problems must be handled by the developer.

Although GET is considered to be idempotent there is nobody stopping the dev to implement a non-idempotent doGET(). This must be avoided.Ideally get must be used to get the data from the server. So the developer must make sure that while implementing doPOST() and doGET() methods he handles idempotency properly or else it will cause issues.
Hope this clears.

Have a look here as well Idempotent
[ January 12, 2008: Message edited by: Deepak Jain ]

[ January 12, 2008: Message edited by: Deepak Jain ]
[ January 12, 2008: Message edited by: Deepak Jain ]

SCJP, SCWCD, SCBCD
Raghavan Muthu
Ranch Hand

Joined: Apr 20, 2006
Posts: 3344

That's a good explanation Deepak

Also the link you have provided contains a very good information and clarifications from the bartenders and other ranchers! Thank you


Everything has got its own deadline including one's EGO!
[CodeBarn] [Java Concepts-easily] [Corey's articles] [SCJP-SUN] [Servlet Examples] [Java Beginners FAQ] [Sun-Java Tutorials] [Java Coding Guidelines]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Idempotent request