hello guys i hope you can help me in here....when should i use the get method or the post method? I already know their meanings etc i just want to ask for some realistic examples especially for those who have already developed many web applications. Thanks....
Hi, This is really an HTTP question. In simple terms, POST is good for passing reasonably large amounts of data, whereas GET is not. GET sticks all your data on the URL, so some people like to use POST for aesthetics. If I remember rightly from the HTTP spec, GET is supposed to be a request for data (hyperlinks basicly) whereas POST is intended for sending data upstream.
Two more suggestions: First: You should never use GET if there is any sensible form data (like passowrds etc) to be transferred, cause the data is attached to the URL and will propably be cached by proxies or browser cache. This makes it very easy to spy them out. Don't get me wrong - POST is not an appropriate method to hide sensible information (You need to have some sort of encryption between Browser and Server for this - like SSL) but it is at least a solution to avoid the Problem explained above. Second: GET has the advantage that form-submissions can be simulated with a link. Like if you want to show somebody the result of a search submission in Google you can give the complete search-URL to somebody. Like this: http://www.google.de/search?q=GET+POST+Method&hl=en&lr=&ie=UTF-8&output=search cheers Hartmut
Usually, use POST if the user is sending information which will be stored on the server, or if the information will be used to update information which is already stored on the server. Use GET for navigating, such as to display an existing record on the server. POST must be used if you are submitting a lot of information, because of the maximum size of a URL (I think its 4K characters). GET has the additional advantage that you can bookmark the resulting address, and use it as a target in a hyperlink. For example, this discussion board arranges to show messages through a GET request. That way, you can bookmark the individual messages, and give links in one message which refer to another message.
Joined: Aug 31, 2002
Originally posted by Michael Zalewski: POST must be used if you are submitting a lot of information, because of the maximum size of a URL (I think its 4K characters).
According to RFC 2068 there is no maximum length limit for a URL defined in the HTTP protocol. It is just some Proxys that cut off URLs which are longer than 4K. Some old browsers even support only URLs up to a maximum length of 255 chars. So to avoid those limitations it is highly recommended that a GET request with all parameters is not longer than 255 chars, while for POST-requests there is virtually no limit at all. sl Hartmut [ September 07, 2002: Message edited by: Hartmut Ludwig ] [ September 07, 2002: Message edited by: Hartmut Ludwig ]