The origin of the ServletConfig object

Discussions

Web tier: servlets, JSP, Web frameworks: The origin of the ServletConfig object

  1. The origin of the ServletConfig object (1 messages)

    Look at the following code snippet, which is a typical init() method from a HttpServlet subclass: ==================================================== public class myServlet extends HttpServlet { public void init(ServletConfig config) throws ServletException { super.init(config); ............................................................................................................. ==================================================== This implementation stores the ServletConfig object it receives from the servlet container for later use. My question is where the particulars of the ServletConfig object come from? Any .xml file or .properties file? My working environment is Tomcat 4.1.
  2. The ServletConfig objectis passed with Initialisation parameteres from the web.xml. In the web.xml of your application say you have marked up as below: .. .. emailHost 151.68.167.201 OS Linux then in your init() method of the corresponding servlet you can retrieve these values public void init(ServletConfig config) throws ServletException { String emailHost = config.getInitParameter("emailHost"); String OS= config.getInitParameter("OS"); }