What is the difference between 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 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.
Usually programmers find it difficult to choose between doGet() and doPost().
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
Following example would help in understand the working of the doGet() and
When you type the word ‘java’ in google search bar and hit enter, this is what
you will find in the address bar:
This is an example of doGet().
Had it been doPost(), you wouldn’t have been able
tosee“hl=en&q=java&meta=” in the address bar.
More Servlets links
Answer - Servlets are Java based analog to CGI programs,
implemented by means of ..........
Answer - RMI (Remote Method Invocation) are a means of
client server communication........
Answer - Servlet mapping controls how you access a
servlet. It is recommended that you don’t use.........