Skip to Content
author's profile photo Former Member
Former Member

servlets

difference between doGet and doPost?

Add comment
10|10000 characters needed characters exceeded

4 Answers

  • author's profile photo Former Member
    Former Member
    Posted on Aug 01, 2006 at 08:59 AM

    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.

    Add comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Aug 01, 2006 at 05:57 AM

    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

    Add comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Aug 01, 2006 at 05:59 AM

    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

    Add comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Aug 01, 2006 at 09:13 AM

    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

    Add comment
    10|10000 characters needed characters exceeded