Hi all, I'm a beginner to web application
I tried to create a simple web application, namely WebTest. It only contains one
servlet, like this:
package solmit;
import java.io.IOException;
import java.io.PrintWriter;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.log4j.Logger;;
public class WebTest extends HttpServlet {
private static Logger log = Logger.getLogger(WebTest.class);
public void doGet(HttpServletRequest request, HttpServletResponse response)
throws IOException, ServletException
{
log.debug("anas: about to enter doGet");
response.setContentType("text/html");
PrintWriter writer = response.getWriter();
writer.println("<html><head><title>Simple Web Application</title></head>");
writer.println("<body><h1>A Simple Web Application</h1>");
writer.println("Here's some text...<br>...and a bit more text");
writer.println("</body></html>");
log.debug("anas: about to leave doGet");
}
}
My web.xml file looks like this:
I also created log4j.properties file in <web-app>/WEB-INF/classes directory. It contains the following code:
I packaged this application into WebTest.war.
When I dropped this package into my
Tomcat (Tomcat 5.5), and tried to access web app using this url :http://localhost:8080/WebTest/start-web-test
I got error messages on my stderr_20080522 log:
Oh, I've also dropped log4j-1.2.13.jar and commons-logging-1.0.4.jar on Tomcat/common/lib
I've read tomcat documentation on logging.. but it seems that it doesn't give me some clue to use log4j logging in my application ("http://localhost:8080/tomcat-docs/logging.html")
I've also already read the documentation about log4j on "http://www.laliluna.de/log4j-tutorial.html"
Could someone give an insight on this ??
Any help would be appreciated
Spec:
Tomcat 5.5
Jre 1.5.0_15
Windows XP Prof edition
Thanks