Apr 21, 2009

GET vs POST

Difference Between GET and POST?

Most HTML pages are static documents that you read in your web browser. But when you really want to interact with a web page, you need some way send data back to the web server. The main way of doing this is with a form. There are two methods you can use with forms to encode data to send it back to the web server. What is the difference between GET and POST?

According to the HTML specifications, GET means that the form data is encoded with the URL that is requested from the web server. The application that receives the data parses out the form data from the URL, and then uses it as input for a query. You know you’re working with a GET query when you see a big long string of variables and values tacked onto the end of a web URL.

One of the advantages of a GET request is that you can bookmark the full URL with all the query information. If you open up the bookmark in your browser, you’ll see the results of the query again.

A POST means that the form data is sent within the message body itself, and is often used when you don’t want to have all this additional information visible in the URL.

GETs can be cached in a user’s browser history, while POSTs typically can’t. This is why you see a warning in your browser that the page will resubmit information to the server.

When developing a form, you should normally use a GET, unless a form submission may cause changes - then you should use POST. You should also use POST if any of the variables will cause the URL to be too long, and might crash a web browser.

You may also want to use POST if you want to make the functionality of your application less visible to users. Although, this isn’t real security. Anyone can just read the source code of your application to understand what variables you’re using.

Labels:

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home