aspose file tools*
The moose likes Web Component Certification (SCWCD/OCPJWCD) and the fly likes init method of Servlet Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Web Component Certification (SCWCD/OCPJWCD)
Bookmark "init method of Servlet" Watch "init method of Servlet" New topic
Author

init method of Servlet

AmitVijay AVKulkarni
Greenhorn

Joined: Apr 26, 2005
Posts: 17
Dear all,

Can anybody explain me the difference between init(ServletConfig config)
method and init() method.
API says simply override no arg init() method which will be called by
init(ServletConfig config) method? What do you mean by this?

Kindly explain.....................


regards,
Amit Kulkarni
Ayesha Tasneem
Greenhorn

Joined: Jan 13, 2005
Posts: 10
Hi,

GenericServletClass implements ServletConfig and Servlet Interface.

the default behavior of GenericServlet class is when init() is invoked it calls init(ServletConfig) this class now has reference of ServletConfig from Servlet Container.
the extending class has to call getServletConfig() to get reference of Config from container.

getServletConfig() method call can be avoided /Extending class can obtain ServletConfig reference by calling super.init(ServletConfig).

Hope this clarifies your doubt.
sarvesh khatri
Greenhorn

Joined: May 05, 2005
Posts: 4
the basic difference I know,

init(ServletConfig) is called by the servlet container to indicate to a servlet that the servlet is being placed into service.

init() is the method you override for doing some stuff at the time of initialization. init() method is called by GenericServlet.init(ServletConfig)
 
wood burning stoves
 
subject: init method of Servlet