File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Servlets and the fly likes init(servletconfig) Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "init(servletconfig)" Watch "init(servletconfig)" New topic
Author

init(servletconfig)

Rajendra Prakash
Ranch Hand

Joined: Sep 10, 2009
Posts: 293
My interviewer asked .which method to be used, either init() or init(servletconfig) or both in generic servlet .
Pramod P Deore
Ranch Hand

Joined: Jul 15, 2008
Posts: 629

init(servletconfig) is available in Servlet interface and init() is available in GenericServlet class. GenericServlet implements Servlet interface, so both can be used in GenericServlet


Life is easy because we write the source code.....
Manish Singh
Ranch Hand

Joined: Jan 26, 2007
Posts: 160
both init() and init(servletconfig) can be used.
But you should use the init() because init(servletconfig) saves the servlet config in an instance variable.

And the sole purpose of init() method is to be overrided be the subclass if needed.
Rajendra Prakash
Ranch Hand

Joined: Sep 10, 2009
Posts: 293
if i override servletconfig() in init() means ,it gives configuration information from server to servlet.
Cofiguration information means can i say about struts-config.xml or hibernate.cfg.xml or something else.
I mean what configuration information you get during initialization.
Fidel Edwards
Ranch Hand

Joined: Mar 19, 2008
Posts: 231
Please refer Servlet FAQ
and ServletConfig


God Gave Me Nothing I Wanted, He Gave Me Everything I Needed.
OCPJP6
 
jQuery in Action, 2nd edition
 
subject: init(servletconfig)