Pr.Pg Next Pg

JSP Form Processing 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/JSP/URLdata.jsp?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.

  • getQueryString() and getParameter() method is use for handling data passed from GET method.

 

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.

  • getParameter() method is use for handling data passed from POST method form and getInputStream() method is use for reading binary data send from client browser.

 

Different between GET and POST method

 

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

POTS 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