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 Servlet Config Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "Servlet Config" Watch "Servlet Config" New topic
Author

Servlet Config

Rajeev Iyer
Ranch Hand

Joined: Jun 19, 2002
Posts: 42
What is the difference between the init() and init(ServletConfig sc) methods in servlets?
How differently does the servlet configure itself based on these mathods?
William Brogden
Author and all-around good cowpoke
Rancher

Joined: Mar 22, 2000
Posts: 12769
    
    5
According to the servlet API, the init( ServletConfig sc ) method is the one that is called by the servlet engine in order to tell the servlet the ServletConfig it will be working under. In early versions of the API this was the only init method - the problem was that your servlet implementation of init( sc ) has to call the parent super.init( sc ) and people kept forgetting to do this.
Therefore, the init( sc ) method in GenericServlet now calls init() - that way there is always an init( sc ) method for the servlet engine to call and your init() can be simpler.
This is all explained in the javax.servlet.GenericServlet JavaDocs.
Bill
 
wood burning stoves
 
subject: Servlet Config