Difference between doGet() and doPost()

What is the difference between doGet() and doPost()?

- doGet() and doPost() are HTTP requests handled by servlet classes.

- In doGet(), the parameters are appended to the URL and sent along with the header information. This does not happen in case of doPost().

- In doPost(), the parameters are sent separately.

- Since most of the web servers support only a limited amount of information to be attached to the headers, the size of this header should not exceed 1024 bytes. doPost() does not have this constraint.

- doGet() shall be used when small amount of data and insensitive data like a query has to be sent as a request.

- doPost() shall be used when comparatively large amount of sensitive data has to be sent. Examples are sending data after filling up a form or sending login id and password.

Following example would help in understand the working of the doGet() and doPost() better:

- When you type the word 'java' in google search bar and hit enter, this is what you will find in the address bar:
http://www.google.co.in/search?hl=en&q=java&meta=
- This is an example of doGet().

- Had it been doPost(), you wouldn't have been able to see "hl=en&q=java&meta=" in the address bar.
What's the difference between servlets and applets?
What's the difference between servlets and applets? - Unlike applets, servlets have no graphical user interface........
What is JSP?
What is JSP? - JSP is a technology that returns dynamic content to the Web client using HTML, XML and JAVA elements....
What is co-variant return type in java?
A covariant return type allows to override a super class method that returns a type that sub class type of super class method’s return type. It is to minimize up casting and down casting......
Post your comment