1. #1
    Unregistered

    How to support both GET and POST Protocol from the same servlet?

    hi
    How do I support both GET and POST protocol from the same Servlet?





  2. Related:
  3. #2
    VEENAMBRUTHA
    Join Date
    Jan 2012
    Posts
    829

    Re: How to support both GET and POST Protocol from the same servlet?

    Quote Originally Posted by Unregistered View Post
    hi
    How do I support both GET and POST protocol from the same Servlet?
    friend,,
    The easy way is, just support POST, then have your doGet method call your doPost method:
    //THE CODE PART IS://

    public void doGet(HttpServletRequest req, HttpServletResponse res)
    throws ServletException, IOException
    {
    doPost(req, res);
    }


    SREVLET LIFE CYCLE:




    GET PROTOCOL:

    [COLOR="rgb(46, 139, 87)"]A GET request is a request to get a resource from the server.
    Choosing GET as the "method" will append all of the data to the URL and it will show up in the URL bar of your browser.
    The amount of information you can send back using a GET is restricted as URLs can only be 1024 characters. [/COLOR]

    POST PROTOCOL:

    [COLOR="rgb(46, 139, 87)"]A POST request is a request to post (to send) form data to a resource on the server.
    A POST on the other hand will (typically) send the information through a socket back to the webserver and it won't show up in the URL bar.
    You can send much more information to the server this way - and it's not restricted to textual data either.
    It is possible to send files and even binary data such as serialized Java objects![/COLOR]
    thankyou!!!




+ Reply to Thread

Quick Reply Any Question?