Header Ads

  • Breaking Now

    What is the difference between doGet and doPost methods of HttpSe?

    A GET or POST request is sent to servlet in order to expedite the request by calling corresponding doGet() and doPost() methods.

    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).
    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).
    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().
    There is a restriction of numbers of parameters to be sent through doGet method around 2k of data can be sent and moreover whole of URL is to be mentioned in case of doGet as mentioned below:
    http://www.xyz.com/servlet?param1=value1&param2=value2&...&paramN=valueN
    So it is always better to use doPost() when sending parameters from a FORM as it doesn't show off information related with password on the network etc.

    Post Top Ad

    Post Bottom Ad