cancel
Showing results for 
Search instead for 
Did you mean: 

servlets

Former Member
0 Kudos

difference between doGet and doPost?

Accepted Solutions (0)

Answers (4)

Answers (4)

Former Member
0 Kudos

hi Lavanya,

doGet is called in response to an HTTP GET request. This happens when users click on a link, or enter a URL into the browser's address bar. It also happens with some HTML FORMs (those with METHOD="GET" specified in the FORM tag). This is mainly used when you want to send small amount of data.

doPost is called in response to an HTTP POST request. This happens with some HTML FORMs (those with METHOD="POST" specified in the FORM tag). this is mainly used when the data is large and you need some secured method to transfer this data(In doGet the data can be seen in the URL)

Both methods are called by the default (superclass) implementation of service in the HttpServlet base class. You should override one or both to perform your servlet's actions. You probably shouldn't override service().

You will find following links useful..

http://www.jguru.com/faq/view.jsp?EID=34956

http://www.esus.com/javaindex/j2ee/servlets/servletdogetdopost.html

Hope this info helps you.

Regards,

Richa

Former Member
0 Kudos

doGet is called in response to an HTTP GET request.When you are querying any information by submitting the form, you use this method.A GET simply wants to retrieve a page without providing much information.

doPost is called in response to an HTTP POST request.A POST, however, can package lots of form or file information with its request. When you are submitting any application forms, say details of your education and career, and submit, then this method will be used. This is used for security reasons, hence data send through url is encrypted.

There is an other method called doPut().A PUT is for uploading a file.

suresh_krishnamoorthy
Active Contributor
0 Kudos

Hi Lavanya,

A doGet() method is limited with 2k of data to be sent, and doPost() method doesn't have this limitation. A request string for doGet() looks like the following:

http://www.allapplabs.com/svt1?p1=v1&p2=v2&...&pN=vN

doPost() method call doesn't need a long text tail after a servlet name in a request.

All parameters are stored in a request itself, not in a request string, and it's impossible to guess the data transmitted to a servlet only looking at a request string.

See this link

http://java.sun.com/j2ee/1.4/docs/tutorial/doc/index.html

Regards

Suresh KB

Former Member
0 Kudos

Hi Lavanya,

doPost

--is used for security reasons.for instance, while sending bank details ,

--large data is send .data send through url is encrypted.

doGet

-- small amount data is send here in the url the data send is visible

Regards

Venkat

Former Member
0 Kudos

thanks for sending