//javac -classpath .:../../../../common/lib/servlet.jar:../lib/log4j-1.2.4.jar:../../../../common/endorsed/xmlParserAPIs.jar Log4JInit.java


import javax.servlet.ServletException;

import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
//import javax.xml.parsers.*;

import java.io.PrintWriter;
import java.io.IOException;

import org.apache.log4j.PropertyConfigurator;
//import org.apache.log4j.xml.DOMConfigurator;

public class Log4JInit extends HttpServlet {
    
    // Initialize the servlet by loading the Log4J properties file
    public void init() throws ServletException {

	// First we get the fully qualified path to the properties file
	String path = getServletContext().getRealPath("/");
	String propfile = path + getInitParameter("propfile");

	// Next we set the properties for all the servlets and JSP
	// pages in this web application
	PropertyConfigurator.configure(propfile);
    }

    // The doPost() method forwards all requests to the doGet() method
    public void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
	doGet(req, resp);
    }

    // The doGet() method informs users of the purpose of this servlet
    public void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
	PrintWriter out = resp.getWriter();

	out.println("<h1>This is a logging initializer servlet</h1>");
    }

    public void destroy() {}

}
