i am a little confused my book says class GenericServlet implements Servlet interface. it further says if i have to override the init() method it is better to call super.init() while overidding the init() method.
I cannot understand which of the two init()'s method is refering to when it says overide. the overloaded init() of GenericServlet or init method of the ServletInterface.
Always override the no-argument init() method... the reason is that the GenericServlet class implements the init(ServletConfig) to save the ServletConfig locally in an instance variable (it can later be obtained by invoking getServletConfig()). The init(ServletConfig) method in GenericServlet then delegates to the no-argument init() which is the one you should implement.
There is no need to invoke super.init() from your init() implementation; indeed, the purpose of this method is to prevent such necessities; from the API documentation:
public void init() A convenience method which can be overridden so that there's no need to call super.init(config).
Hope that helps!
Charles Lyons (SCJP 1.4, April 2003; SCJP 5, Dec 2006; SCWCD 1.4b, April 2004)
Author of OCEJWCD Study Companion for Oracle Exam 1Z0-899 (ISBN 0955160340 / AmazonAmazon UK )