There are many differences between the Get and Post request. Let’s see these differences:

GET POST
1) In case of Get request, only limited amount of data can be sent because data is sent in header. In case of post request, large amount of data can be sent because data is sent in body.
2) Get request is not secured because data is exposed in URL bar. Post request is secured because data is not exposed in URL bar.
3) Get request can be bookmarked. Post request cannot be bookmarked.
4) Get request is idempotent . It means second request will be ignored until response of first request is delivered Post request is non-idempotent.
5) Get request is more efficient and used more than Post. Post request is less efficient and used less than get.

Get vs. Post

GET and POST

Two common methods for the request-response between a server and client are:

  • GET– It requests the data from a specified resource
  • POST– It submits the processed data to a specified resource

Anatomy of Get Request

The query string (name/value pairs) is sent inside the URL of a GET request:

GET/RegisterDao.jsp?name1=value1&name2=value2

As we know that data is sent in request header in case of get request. It is the default request type. Let’s see what information is sent to the server.

Servlet Request6

Some other features of GET requests are:

  • It remains in the browser history
  • It can be bookmarked
  • It can be cached
  • It have length restrictions
  • It should never be used when dealing with sensitive data
  • It should only be used for retrieving the data

Anatomy of Post Request

The query string (name/value pairs) is sent in HTTP message body for a POST request:

POST/RegisterDao.jsp HTTP/1.1  
Host: www.codebridgeplus.com  
name1=value1&name2=value2

As we know, in case of post request original data is sent in message body. Let’s see how information is passed to the server in case of post request.

Servlet Request7

Some other features of POST requests are:

  • This requests cannot be bookmarked
  • This requests have no restrictions on length of data
  • This requests are never cached
  • This requests do not retain in the browser history