I am trying to specify init context parameters in the default context in server.xml as 
follows:
  <Context path="" docBase="ROOT" debug="0">
      <Parameter name="configDir" value="C:\config" override="false"/>
  </Context>
This is the only context I have listed in server.xml. Then I have my Servlet class as 
follows:
  public abstract class JdbcServlet extends HttpServlet
  {
      public void init(ServletConfig config) throws ServletException
      {
          super.init(config);
          String configDir = getServletContext().getInitParameter("configDir");
          System.out.println("configDir = " + configDir);
      }

      ...

  }
This prints out: "configDir = null" rather than "configDir = C:\config" as I would 
expect.

It only works if I specify the parameter in a more specific context as follows:
  <Context path="/mycontext" docBase="/mycontext" debug="0">
      <Parameter name="configDir" value="C:\config" override="false"/>
  </Context>
I have tried this with Tomcat 4.1.30 and 5.0.19 with the same results.

Reply via email to