There is a convenience method init() in GenericServlet (note it takes no parameters) that you should override if you want to provide 'subclass specific features', and not override the init(SevletConfig) method.
In my version of Tomcat 5.0.28 (I Think) this is all that the init(ServletConfig) method does. This may not be the same on all versions of Tomcat or on all web containers.
Joined: Nov 15, 2004
I think u didn't understand my question.
I know there is a convenience init() method thats takes no argument which we are supposed to override.
But I want to know why we should call super.init(ServletConfig) if we override the init() method that take a ServletConfig instance.
Joined: Jul 20, 2005
1) Different containers may be doing different things in the init(ServletConfig) method. Therefore if you are possibly going to change the container that your application runs on, to ensure that the container does everything it needs to do, you should call super.init(ServletConfig).
2) In Tomcat, at least the version I am running, ServletConfig is defined in GenericServlet as 'private transient ServletConfig config;' this means that you CAN'T do everything that the super.init(ServletConfig) does. If you call getServletConfig() in a servlet that has overriden the init(ServletConfig) method and not called super.init(ServletConfig) you will get null.
3) It is generally bad practice, init() is provided for this very reason. Therefore others maintaing your code will probably not be thinking that they can't call getServletConfig(), or that something else may be broken because you overrode init(ServletConfig) rather than init().