Edit Edit

Java Servlet FAQ


How do you retrieve an initialization parameter?


public void init(ServletConfig config) throws ServletException
{
    String initparam1 = config.getInitParameter("initparam1");
}

public void init(ServletConfig config) throws ServletException
{
    Enumeration enum = config.getInitParameterNames();

    // echo the init parameter names and values back to the debug console
    while (enum.hasMoreElements()) {
        String name = (String) enum.nextElement();
        System.out.println("Init Parameter Name: " + name +
                           " Value: " + config.getInitParameter(name));
    }
}



Last updated 12/18/1999 01:31:36 PM