aspose file tools*
The moose likes Web Component Certification (SCWCD/OCPJWCD) and the fly likes Servlet LifeCycle? 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 LifeCycle?" Watch "Servlet LifeCycle?" New topic
Author

Servlet LifeCycle?

Joe Harry
Ranch Hand

Joined: Sep 26, 2006
Posts: 9426
    
    2

Guys,

I have a small doubt is that what is the actual need of the service method since we are not doing anything with that?? I mean, we only override doGet or doPost...so why do we actually need the service method even?? This may be a silly question but I could not refrain myself from asking it.


SCJP 1.4, SCWCD 1.4 - Hints for you, Certified Scrum Master
Did a rm -R / to find out that I lost my entire Linux installation!
Christophe Verré
Sheriff

Joined: Nov 24, 2005
Posts: 14688
    
  16

There's no silly question.
And the answer is in the FAQ:
http://faq.javaranch.com/view?ServletsFaq#9


[My Blog]
All roads lead to JavaRanch
Joe Harry
Ranch Hand

Joined: Sep 26, 2006
Posts: 9426
    
    2

So as per the faq says, "The only thing the service method does is examining the HTTP method, and based on that, dispatch the request to the various doXYZ methods" is the real purpose of service method!

Thanks Satou. You have been really helpful!
Rajesh Seeram
Greenhorn

Joined: Dec 28, 2006
Posts: 9
Hi,

"The only thing the service method does is examining the HTTP method, and based on that, dispatch the request to the various doXYZ methods"

This statement is only applicable to HttpServlet not for Generic Servlet. As HttpServlet is implemented for HTTP Protocol, where as if you want to implement a Servlet for SMTP or some other protocol you need a service method.


Rajesh Seeram<br />-------------<br />SCJP 1.4 (98%)
Joe Harry
Ranch Hand

Joined: Sep 26, 2006
Posts: 9426
    
    2

Thanks Rajesh for the explanation. It got my doubt cleared!
 
jQuery in Action, 2nd edition
 
subject: Servlet LifeCycle?