This week's giveaway is in the EJB and other Java EE Technologies forum.
We're giving away four copies of EJB 3 in Action and have Debu Panda, Reza Rahman, Ryan Cuprak, and Michael Remijan on-line!
See this thread for details.
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 EJB 3 in Action this week in the EJB and other Java EE Technologies 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: 9243
    
    1

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, SCBCD Hints - Demnachst, SCDJWS - Auch Demnachst
Did a rm -R / to find out that I lost my entire Linux installation!
Christophe Verré
Sheriff

Joined: Nov 24, 2005
Posts: 14687
    
  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: 9243
    
    1

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: 9243
    
    1

Thanks Rajesh for the explanation. It got my doubt cleared!
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Servlet LifeCycle?
 
Similar Threads
doubt in http methods
service method in httpservlet
init method of servlets
Session Maintenanace in Web Services
overridding service()