aspose file tools*
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 Spring in Action this week in the Spring 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: 42285
    
  64
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.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: How does servlet decide which init method to call