Search This Blog

Thursday 22 December 2016

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

While using doGet() or doPost() prefer using doPost() because it is secured and it can send much more information to the server.

GET or doGet()

GET is the simples HTTP method, and its main purpose is to ask a server to get a resource and send it back. The resource can be an HTML page, an image , a PDF etc.

  • The request parameters are transmitted as a query string appended to the request.
  • All the parameters get appended to the URL in the address bar.
    http://example.com/search?emp_name=sanjay 
  • Allows browser bookmarks but not appropriate for transmitting private or sensitive information. 
  • In an HTML you can specify as follows:
    <form name=”myForm” method=”GET” >
  • GET was originally intended for static resource retrieval.
  • GET is not appropriate when large amounts of input data are being transferred.



POST or doPost()

HTTP Post request is more powerful and used by the browser to make complex requests on the server. For example the user fills up a form and submit the data , which is then supposed to be inserted into a database.

The request parameters are passed with the body of the request.

More secured. In HTML you can specify as follows:
<form name=” myForm” method=”POST” >
POST was intended for form submits where the state of the model and database are expected to change.

Since POST sends information through a socket back to the server and it won’t show up in the URL address bar, it can send much more information to the server.



Unlike doGet(), it is not restricted to sending only textual data. It can also send binary data such as serialized Java objects.

No comments:

Post a Comment