M Sach
M Sach

Reputation: 34424

Use of HTTP Post method?

Below is the statement written at http://hateinterview.com/java-script/methods-get-vs-post-in-html-forms/1854.html

By specification, GET is used basically for retrieving data where as POST is used for data storing, data updating, ordering a product or even e-mailing

Whenever i used get or post method, i used them to get the parameters with getparameter() method of httprequest. I did not get in above statement, how post method is used for datastoring or dataupdation which we cant achieve with get method. Looking for a very brief example.

EDIT: Thanks all for your answers but i am specifically looking for meaning of data storing, data updating in post method apart from file loading stuff.

Upvotes: 0

Views: 606

Answers (5)

Pete Wilson
Pete Wilson

Reputation: 8694

@Mohit edited his question to add: "Thanks all for your answers but i am specifically looking for meaning of data storing, data updating in post method apart from file loading stuff. "

Read rfc2616, Hypertext Transfer Protocol -- HTTP/1.1, specifically Sections 9.3 GET and 9.5 POST:

"The GET method means retrieve ... information."

"The POST method is used to request that the origin server accept" information.

To be strictly compliant with rfc2616, use the GET method to read data from the server. Use the POST method to write data to the server.

The "meaning of data storing, data updating" is exactly that. How could this possibly be any clearer or more explicit?

Upvotes: 1

Pete Wilson
Pete Wilson

Reputation: 8694

One difference is that the GET data (in the URL, as another answer says) show up at a *nix server as the contents of the environment variable QUERY_STRING, whereas POST data appear on stdin. Regardless of how they are packaged and sent, GET and POST data are identical in format, in my experience.

Upvotes: 1

BalusC
BalusC

Reputation: 1108537

GET can in theory also store and update data, but it's simply not safe. It's too easy to accidently store or update data by just bookmarking it, following a link or being indexed by a searchbot. POST requests are not bookmarkable/linkable and not indexed by searchbots. Also, the GET query string has a limited length, the safe limit is 255 characters. The POST request body can however be as large as 2GB. Also, uploading files is not possible by GET.

Upvotes: 2

undone
undone

Reputation: 7888

there are things you can not do with GET !
first of them is with post you can upload files!
See this: Article or this one

Upvotes: 0

Yahia
Yahia

Reputation: 70369

POST sends the data in the body while GET puts the data in the URL...

For example to upload a file you use POST... since GET puts the data into URL the data is visible to the user and the length is limited.

see for example http://www.cs.tut.fi/~jkorpela/forms/methods.html

Upvotes: 0

Related Questions