Results 1 to 4 of 4

Thread: doGet() & doPost()

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Expert Member
    Join Date
    Oct 2006
    Answers
    209

    doGet() & doPost()

    what are doGet() & doPost() methods and what is difference between doGet () and doPost()?

    This is the question asked by visitor RAVI R K]


  2. #2
    Contributing Member
    Join Date
    Sep 2006
    Answers
    962

    Re: doGet() & doPost()

    The doGet and doPost methods are called in response to an HTTP GET and an HTTP POST respectively which are submission methods used in an HTML FORM. On an HTTP GET the form data is part of the URL whereas on an HTTP POST the form data appears in the message body. You should always have one method call the other in your servlet as processing the form data in a servlet is consistent regardless of the submission method. For example:


    public void doGet(HttpServletRequest req, HttpServletResponse resp)
    {
    doPost(req,resp);
    }

    public void doPost(HttpServletRequest req, HttpServletResponse resp)
    {
    //process the incoming request
    }



    Difference between doGet and doPost mehtods......

    DoGet
    1)In doGet Method the parameters are appended to the URL and sent along with header information
    2)Maximum size of data that can be sent using doget is 240 bytes
    3)Parameters are not encrypted
    4)DoGet is faster if we set the response content length since the same connection is used. 5)Thus increasing the performance
    6)DoGet should be idempotent. i.e. doget should be able to be repeated safely many times
    7)DoGet should be safe without any side effects for which user is held responsible

    DoPost
    1)In doPost, parame
    ters are sent in separate line in the body
    2)There is no maximum size for data
    3)Parameters are encrypted
    4)Dopost is generally used to update or post some information to the server
    5)DoPost is slower compared to doGet since doPost does not write the content length
    6)This method does not need to be idempotent. Operations requested through POST can have side effects for which the user can be held accountable, for example, updating stored data or buying items online
    7)This method does not need to be either safe

    I think its useful for u.....

    --------------------------------------

    suresh


  3. #3
    Contributing Member
    Join Date
    Jun 2006
    Answers
    95

    Re: doGet() & doPost()

    good answer Suresh.


  4. #4
    Junior Member
    Join Date
    Nov 2006
    Answers
    2

    Thumbs up Re: doGet() & doPost()

    [QUOTE=JobHelper;3397]what are doGet() & doPost() methods and what is difference between doGet () and doPost()?

    doGet,do post are the methods avilable in HttpServlet Class

    doGet():- is used to get the information from the servlet

    doPost():- is used to post the information in the servlets

    Chheers,

    Kailash


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
About us
Applying for a job can be a stressful and frustrating experience, especially for someone who has never done it before. Considering that you are competing for the position with a at least a dozen other applicants, it is imperative that you thoroughly prepare for the job interview, in order to stand a good chance of getting hired. That's where GeekInterview can help.
Interact