This week's book giveaway is in the JavaScript forum.
We're giving away four copies of Cross-Platform Desktop Applications: Using Node, Electron, and NW.js and have Paul Jensen on-line!
See this thread for details.
Win a copy of Cross-Platform Desktop Applications: Using Node, Electron, and NW.js this week in the JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

query about GET and POST methods  RSS feed

 
amit daundkar
Ranch Hand
Posts: 47
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hello friends,

i have a small query. We use GET for getting a response and POST to post to server. taken into account the security related and other differences between the two methods,
we can still 'GET' a response using the POST method. so why to use GET? i mean y are there two different methods if one of them can perform the same tasks.

may sound a dumb question.but please reply.

thank you.
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 66141
141
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ou have some incorrect concepts around these HTTP methods, and HTTP in general.
amit daundkar wrote:i have a small query. We use GET for getting a response and POST to post to server.
Not quite. All requests will result in a response, be they GET, POST, PUT, DELETE, or any other HTTP method.

The difference is in how the methods are to be used.

taken into account the security related and other differences between the two methods,
There is no difference in security between any of the methods. None. At all.

we can still 'GET' a response using the POST method. so why to use GET?
GET is intended for just what is says -- to GET something from the server. GETs should be idempotent -- that is, repeating the same GET over and over again should get the same response.

GETs pass request parameters on the URL.

POSTs can be non-idempotent, that is, return different response results based upon what happens on the server.

POSTs pass request parameters in the request body.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!