// See also The Quintessential Servlet

// This method is called by the servlet container just before this servlet
// is put into service.
public void init() throws ServletException {
    getServletContext().log("getinit init");
    // Get the value of an initialization parameter
    String value = getServletConfig().getInitParameter("param1");

    // Get all available intialization parameters
    java.util.Enumeration enum = getServletConfig().getInitParameterNames();
    for (; enum.hasMoreElements(); ) {
        // Get the name of the init parameter
        String name = (String)enum.nextElement();

        // Get the value of the init parameter
        value = getServletConfig().getInitParameter(name);

    // The int parameters can also be retrieved using the servlet context
    value = getServletContext().getInitParameter("param1");

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.