This week's book giveaway is in the OCMJEA forum.
We're giving away four copies of OCM Java EE 6 Enterprise Architect Exam Guide and have Paul Allen & Joseph Bambara on-line!
See this thread for details.
The moose likes Web Component Certification (SCWCD/OCPJWCD) and the fly likes doGet() and doPost() Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCM Java EE 6 Enterprise Architect Exam Guide this week in the OCMJEA forum!
JavaRanch » Java Forums » Certification » Web Component Certification (SCWCD/OCPJWCD)
Bookmark "doGet() and doPost()" Watch "doGet() and doPost()" New topic
Author

doGet() and doPost()

Val Lee
Ranch Hand

Joined: Nov 27, 2001
Posts: 41
Both doGet() and doPost request,as well as,doGet() call doPost() in servlet.why to use?
thanks.


Val SCJP2 1.2<br />====>SCJD
Kyle Tang
Ranch Hand

Joined: Aug 22, 2002
Posts: 78
sorry I can't understand what you are talking about. doGet() does NOT have to call doPost(), in case you are looking at an example where the doGet just simply calls doPost. that just mean that particular servlet doesn't care whether it is GET or POST.
Kyle


Kyle Tang<br />SCJP 91<br />SCWCD 96<br />SCBCD 95
Val Lee
Ranch Hand

Joined: Nov 27, 2001
Posts: 41
sorry,
e.g.
Kyle Tang
Ranch Hand

Joined: Aug 22, 2002
Posts: 78
yeah, you define both doGet and doPost because your servlet wanna handle both GET and POST HTTP requests.
but if your doGet calls doPost, or doPost calls doGet, that just means your servlet treats both GET and POST in the same way, and generates the same response.
your doGet never has to call doPost, and the same for doPost. That example is just an example.
Kyle
Val Lee
Ranch Hand

Joined: Nov 27, 2001
Posts: 41
Thanks!I see!
Maha Annadurai
Ranch Hand

Joined: Oct 27, 2002
Posts: 87
If you just override doPost(req,res) alone , you are making an assumption that you support only POST requests. If in case, you call this servlet through browser address link, then you will get "500 Http Method Not Supported" error.
Usually, during development stage, we may want to check if the servlet functions well, by invoking the servlet directly from browser address bar. Making the servlet call doPost() from doGet() is an easy way to overcome this 500 server error (Default implementation) and helps us to proceed with our testing.
Regards,
Maha Anna
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: doGet() and doPost()