|
Java™ by example!
|
|
|
How do I get started with Servlets using Tomcat?
This step-by-step explanation shows you how to run your first servlet with Tomcat, the official reference implementation for the Java Servlet 2.2 and JavaServer Pages 1.1 technologies. 1) Download Tomcat which is a Servlet/JSP engine that allows you to deploy and execute Servlets. http://jakarta.apache.org/downloads/binindex.html 2) Set the environment variable JAVA_HOME to your current Java development kit: (on Windows)
3) Create the following directory structure:
4) Create the Java Servlet HelloWorldServlet.java and put the .class file in webapps\helloworld\WEB-INF\classes HelloWorldServlet.java:
5) Create web.xml and put it in \webapps\helloworld\WEB-INF. web.xml:
6) Modify server.xml that is located in \conf and have it include our Web Application using a new Context entry:
7) Start the Tomcat webserver. Tomcat includes a small HTTP server mainly for testing reasons. It is recommended that real-world sites use a web server such as Apache for static pages and use Tomcat as a Servlet/JSP add-on.
8) Test the HelloWorldServet! Type in your web browser:
Further Information
Author of answer: Joris Van den Bogaert
Comments
Comments to this answer are only viewable by members. Login or become a member!
|
|
|
|
|