This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes Servlets and the fly likes How does servlet decide which init method to call Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "How does servlet decide which init method to call" Watch "How does servlet decide which init method to call" New topic
Author

How does servlet decide which init method to call

Satish Kota
Ranch Hand

Joined: Feb 08, 2006
Posts: 88
If i have a servlet which overrides both init() and init(ServletConfig) method. How does ServletContainer decide which init method to call?


SCJP 5.0 77%
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 41068
    
  43
In the javadocs for the Servlet interface, you'll find only init(ServletConfig), so that's what the container will call. It can't assume that there will be an init() method (a servlet doesn't need to extend GenericServlet or HttpServlet, after all).


Ping & DNS - my free Android networking tools app
Peter Chase
Ranch Hand

Joined: Oct 30, 2001
Posts: 1970
Originally posted by Satish Kota:
If i have a servlet which overrides both init() and init(ServletConfig) method.


Why would you do that?


Betty Rubble? Well, I would go with Betty... but I'd be thinking of Wilma.
David O'Meara
Rancher

Joined: Mar 06, 2001
Posts: 13459

Also, the Javadoc descriptions describe how each will be used. The Javadoc is your friend.
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: How does servlet decide which init method to call
 
Similar Threads
Servlet Destroy() Method
Overriding both versions of init() method
confusion in init() and init(ServletConfig)
Servlet init method
Clarification abt init()