File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Web Component Certification (SCWCD/OCPJWCD) and the fly likes servlet question Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Certification » Web Component Certification (SCWCD/OCPJWCD)
Bookmark "servlet question" Watch "servlet question" New topic
Author

servlet question

deepak kukreja
Ranch Hand

Joined: Aug 13, 2001
Posts: 54
Hi
'm new to servlets.
Just know that there are methods named doXXX() and getXXX()
Could somebody tell me which case we use doGet() and in which we
use doPost().
One more method, service is availbale. If suppose I
send a 'get' request, which methods will be called? in which sequence


Deepak<br />SCJP
Paul Anilprem
Enthuware Software Support
Ranch Hand

Joined: Sep 23, 2000
Posts: 3313
    
    7
Well, the names of the methods giveaway what should they be used for. doGet() for implementing GET request (for eg. clicking on a URL) and doPost() for POST requests (for eg. submitting a form).
You don't need to implement service(...) methods. GenericServlet and its subclass HttpServlet (from which you'll extend your servlet) implement them appropriately. The servlet container calls service(ServletRequest, ServletResponse). This method calls service(HttpServletRequest, HttpServletResponse), whic(implemented in HttpServlet), determines the request type (GET, POST, etc) and calls the respective method.
HTH,
Paul.


Enthuware - Best Mock Exams and Questions for Oracle/Sun Java Certifications
Quality Guaranteed - Pass or Full Refund!
Paul Anilprem
Enthuware Software Support
Ranch Hand

Joined: Sep 23, 2000
Posts: 3313
    
    7
BTW, you should read this stuff from http://www.amazon.com/exec/obidos/ASIN/1930110596/jdiscuss-20. It explains it very nicely from the exam point of view.
 
jQuery in Action, 2nd edition
 
subject: servlet question