Difference between GET and POST methods
- Fundamental Difference is probably the Visibility - GET request is sent via the URL string (appended to the URI with a question-mark as separator), which is visible whereas POST request is encapsulated in the body of the HTTP request and can't be seen.
- Length - Since, GET request goes via URL, so it has a limitation for its length. It can't be more than 255 characters long (though this is browser dependent, but usually the max is 255 characters only). Whereas no such maximum length limitation holds for the POST request for the obvious reason that it becomes a part of the body of the HTTP request and there is no size limitation for the body of an HTTP request/response.
- Performance - GET request is comparatively faster as it's relatively simpler to create a GET request and the time spent in the encapsulation of the POST request in the HTTP body is saved in this case. In addition, the maximum length restriction facilitates better optimization of GET implementation.
- Type of Data - GET request is sent via URL string and as we all know that URL can be text-only, so GET can carry only text data whereas POST has no such restriction and it can carry both text as well as binary data.
- Caching/Bookmarking - again for the obvious reason that a GET request is nothing but an URL hence it can be cached as well as Bookmarked. No such luxuries with a POST request.
- FORM Default - GET is the default method of the HTML FORM element. To submit a FORM using POST method, we need to specify the method attribute and give it the value "POST".
- Data Set - GET requests are restricted to use ASCII characters only whereas POST requests can use the 'enctype' attribute with a value "multipart/form-data" to use the Universal Multiple-Octet Coded Character Set (UCS).
When to use what?
HTML 4.01 Specification says in the section 17.13.1 Form Submission method:
The "get" method should be used when the form is idempotent (i.e., causes no side-effects). Many database searches have no visible side-effects and make ideal applications for the "get" method.
If the service associated with the processing of a form causes side effects (for example, if the form modifies a database or subscription to a service), the "post" method should be used.
I think the above W3C Recommendation makes it pretty clear when to use the GET method and when to use the POST method.
|
|
|
16 comments:
good 1 very well explaine thanku
very well explained. thanks.
nice and clear explanations. gud job.
BEST EXPLANATION.............
Keep UP THE GOOD WORK^^^^^^^^^^^^
Best explanation of differences between GET and POST on the Web. +1 for your efforts.
Thanks,
~Pawankumar Jajara
Thanks for clear xplaination
nice explanation...simple and clear
THANKS,NICELY EXPLAINED!!
Good work....
wow....!
this is fantastic....
Very good explained. and easy to understanding. Thanks a Lots...!
Conventionally, you use the doPost() method in a Java servlet to change some data in the server’s database.
And you use the doGet() method to request the server for a view of the data in the database.
Thanks,
GayMan
Well said it.....couldn't of put it simplier
Really it's very good......
Woah! I'm really enjoying the template/theme of this blog. It's ѕіmplе, yet effective.
A lοt of tіmеѕ it's hard to get that "perfect balance" between superb usability and visual appeal. I must say you have done a amazing job with this. Additionally, the blog loads extremely quick for me on Safari. Outstanding Blog! Kamagra bestellen Super Kamagra
My homepage Super Kamagra
ver clear explanation
Simple, clear, beautiful!! Why can't we all be like this guy?
Post a Comment