Logo 
Search:

Java Forum

Ask Question   UnAnswered
Home » Forum » Java       RSS Feeds

Why doGet() method inside a doPost() method?

  Asked By: Bailey    Date: Mar 21    Category: Java    Views: 6974
  

Do you know what is the use to have a doGet() method
inside a doPost() method in servlet like the
following?


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

Share: 

 

5 Answers Found

 
Answer #1    Answered By: Oscar Evans     Answered On: Mar 21

Get and Post differ in the way server treats them and you can easily do
the same thing get does in post as long as you don't care. This servlet
responds similar to both post and get requests.

 
Answer #2    Answered By: Michael Evans     Answered On: Mar 21

We use doGet() method  inside the doPost() method to go from DoPost method to DoGet method.

 
Answer #3    Answered By: Woodrow Jones     Answered On: Mar 21

doGet() and doPost() are called in different
ocassions, when you call an URL you normally make a
GET request, when you put a form and set the <FORM
METHOD=POST> then you have a post request. Forms can
be either get or post, so to process a form request
yuou may program both methods or you mey loose some
requests
so, the easieste way is to call doPost() from doGet()
or viceversa or point both of them to your function.

 
Answer #4    Answered By: Iris Sanders     Answered On: Mar 21

you'd better override these two methods separately . but if you use nested forms or some several frames with separate forms(maybe each form has its own method), in your HTML tags you may need to impelemnting doGet() within doPost() method  .

 
Answer #5    Answered By: Olga Allen     Answered On: Mar 21

This is the proposed default implementation in servlet  specification.
If for some reasons you need to handle these methods separately you
can override them.

 
Didn't find what you were looking for? Find more on Why doGet() method inside a doPost() method? Or get search suggestion and latest updates.




Tagged: