This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
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 Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Certification » Web Component Certification (SCWCD/OCPJWCD)
Bookmark "servlet question" Watch "servlet question" New topic

servlet question

deepak kukreja
Ranch Hand

Joined: Aug 13, 2001
Posts: 54
'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: 3254
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.

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: 3254
BTW, you should read this stuff from It explains it very nicely from the exam point of view.
I agree. Here's the link:
subject: servlet question
Similar Threads
Use of marker interface
Mapping xmlschema to excel sheet using JAXB
how to create a new entity bean without insert new records
How to apply a tooltip to tabs on a DecoratedTabPanel