What is the 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 the 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:
http://www.google.co.in/search?hl=en&q=java&meta=
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.
Difference between using getSession(true) and getSession(false) methods
getSession(true) will check whether a session already exists for the user. If yes, it will return that session object else it will create a new session...
Difference between a JavaBean from a Servlet
Servlet and JavaBean - Servlets are Java based analog to CGI programs, implemented by means of a servlet container associated with an HTTP server...
How servlets differ from RMI
Servlet and RMI - RMI (Remote Method Invocation) are a means of client server communication. In this, the client invokes a method on the server machine..
Post your comment
Discussion Board
Comment
Good eplanation
Ranganath 03-9-2013