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


Interview questions

Difference between doGet() and doPost()


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 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:

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.

NEXT>>< /H5>

Write your comment - Share Knowledge and Experience

Discussion Board

Good eplanation

Ranganath 03-9-2013 02:57 AM


More Servlets links

List out the difference between a JavaBean from a Servlet?

Answer - Servlets are Java based analog to CGI programs, implemented by means of ..........

Explain how servlets differ from RMI. Explain the advantages and disadvantages of each technology.

Answer - RMI (Remote Method Invocation) are a means of client server communication........

Define servlet mapping.

Answer - Servlet mapping controls how you access a servlet. It is recommended that you don’t use.........

Latest placement tests
Latest links
Latest MCQs
» General awareness - Banking » ASP.NET » PL/SQL » Mechanical Engineering
» IAS Prelims GS » Java » Programming Language » Electrical Engineering
» English » C++ » Software Engineering » Electronic Engineering
» Quantitative Aptitude » Oracle » English » Finance
Home | About us | Sitemap | Contact us