This week's book giveaway is in the JavaScript forum.
We're giving away four copies of Cross-Platform Desktop Applications: Using Node, Electron, and NW.js and have Paul Jensen on-line!
See this thread for details.
Win a copy of Cross-Platform Desktop Applications: Using Node, Electron, and NW.js this week in the JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Servlet Config  RSS feed

 
Rajeev Iyer
Ranch Hand
Posts: 42
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 13078
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Consider Paul's rocket mass heater.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!