Pr.Pg Next Pg

Servlets Form Data tutorials

  • You must have come across a situation where you need to pass some information from your browser to a web server for processing the data or booking some E-AirLine tickets online.

  • For passing data from browser to web server, browser uses two method, GET method and POST method.

 

GET method

  • GET method appends form-data into the URL in name/value pairs.

  • GET method URL look like below:

http://localhost:8080/WebApplication1/URLdata?First_Name=Rahul&Last_Name=Dev&Sex=Male

  • The length of a URL is limited about 3000 characters so large amount of data cannot be send using GET method.

  • You should never use GET for sending sensitive data like username, password or else it will be visible in the URL bar.

  • GET method is use full for form submissions where a user want to bookmark the result.

  • GET is better for non-secure data.

  • Servlet handles GET method request by using doGet method of servlet.

 

POST method

  • POST method do not appends form-data into URL.

  • POST method request are never cached.

  • POST method request do not remain in the browser history.

  • POST method request have no data limit restriction, it can send any amount of data.

  • POST method request cannot be bookmarked.

  • Servlet handles POST method request by using doPost method of servlet.

 

Different between GET and POST

 

Sr No

GET

POST

1

GET is a default method for sending data through HTML form.

POST primarly defined for sending data through HTML form

2

GET can be bookmarked

POST cannot be bookmarked.

3

Using GET we can send only ASCII characters

Using POST we can send any data including binary data also.

4

GET method data are visible to every one in URL bar of the web browser.

POST method data are not visible in URL bar of the web browser.

5

GET method should not be used when sending password or other sensitive data.

POST method should be used when sending password and other sensitive data.

6

GET method data can be cached.

POST method data can not be cached.

Pr.Pg border                                              Next Pg