Win a copy of Reactive Streams in Java: Concurrency with RxJava, Reactor, and Akka Streams this week in the Reactive Progamming forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Junilu Lacar
  • Jeanne Boyarsky
  • Bear Bibeault
Sheriffs:
  • Knute Snortum
  • Tim Cooke
  • Devaka Cooray
Saloon Keepers:
  • Ron McLeod
  • Stephan van Hulst
  • Tim Moores
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Piet Souris
  • Frits Walraven
  • Ganesh Patekar

idempotent vs non-idempotent

 
Ranch Hand
Posts: 401
Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
GET method is said to be idempotent and post method is said to be non-idempotent. So will it create any problem when we use non-idempotent methods like post when I send identical requests?

If I want to send identical requests should I use only doGet()?

Pls tell me where my logic is going wrong


Thanks and regards
Rahul Roy.
 
Marshal
Posts: 67289
170
Mac Mac OS X IntelliJ IDE jQuery Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
While the GET method was intended to be idempotent, you can actually do anything you want with code on the server. Same with POST operations.

If you want to follow the intentions of the HTTP protocol, be sure to code your apps such that GETs don't change server state, and to use POSTs when server state may change.
 
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
can anybody tell me the diff between idempotent and non-idempotent, w.r.t doGet and doPost methods
 
Sheriff
Posts: 13411
Firefox Browser VI Editor Redhat
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Lucky Chawla,
Two things:

OneWelcome to JavaRanch!

We're pleased to have you here with us in the Servlets forum, but there
are a few rules that need to be followed, and one is that proper names are
required. Please take a look at the
JavaRanch Naming Policy and
adjust your display name to match it.

In particular, your display name must be a first and a last name separated by a space character, and must not be obviously fictitious.

You can change it here


Second:
In an effort to help you get the most from our forums, we've compiled a
list of tips for asking questions here. You can find the list in our
FAQ section here.
In particular please see:
UseRealWords


Abbreviations such as "u" or "ur" in
place of "you" and "you are" or "you're" confound language translation software making
it hard for our non-English speaking members to read your posts.
"plz" is not a word in the English language.

Please edit your last post and remove the "w.r.t.." section.
"diff" is not a word in the English languge.

Again, welcome to JavaRanch and good luck with your question.
-Ben
 
Lucky Chawla
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ya you are right , I myself think my lanugage to ask a question is not correct. I will recorrect my question:
can anybody tell me the difference between idempotent and non-idempotent, with respect to doGet and doPost methods ?
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser VI Editor Redhat
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
HttpServlets are built to work over HTTP so maybe it's better to understand the intent of the designers of the HTTP spec.
This page does a good job explaining it:
http://en.wikipedia.org/wiki/HTTP#Idempotent_methods

As Bear mentioned, it is up to you to follow these recommendations (or not to).
Nothing in the servlet spec will enforce this.
Browsers will warn people if they try to refresh or back into a non-cached page that was created from the result of a POST operation.
 
Rauhl Roy
Ranch Hand
Posts: 401
Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Ben Souther:
HttpServlets are built to work over HTTP so maybe it's better to understand the intent of the designers of the HTTP spec.
This page does a good job explaining it:
http://en.wikipedia.org/wiki/HTTP#Idempotent_methods

As Bear mentioned, it is up to you to follow these recommendations (or not to).
Nothing in the servlet spec will enforce this.
Browsers will warn people if they try to refresh or back into a non-cached page that was created from the result of a POST operation.


Hello Mr.Ben Souther,


I have a doubt.

1. Senario.

As per your suggested link Idempotent means multiple identical requests should have the same effect as a single request

does it mean...

I want to create a small application. In which, there is an option for buying books which includes note-books also.

First my customer wanted to buy a note-book through my web-site after getting the confirmation from the server, he wanted to buy same book again.

In this situation what should I do ? am I supposed to use only doPost() instead of doGet()???

If I use doGet() will my customer be able to buy only one book???

Don't idempotent methods recognise my 2 request?

Regards,
Rauhl Roy.

 
Forget this weirdo. You guys wanna see something really neat? I just have to take off my shoe .... (hint: it's a tiny ad)
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!