This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
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 Android Security Essentials Live Lessons this week in the Android 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
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: init(servletconfig)
 
Similar Threads
Final value in a Servlet
about GenericServlet
Init method with,without argument
Doubt in Servlets
passing ServletContext