esuslogo
 [To advertise Java(tm) Events here, contact joris@esus.com!]
banner

Java™
by example!






New @ Esus.com


  gb  In-house search engine for better results!

  gb  Get updates with the esus.com
newsletter!









  Home 
 Browse Categories 
 Ask a Java Question 
 Help 
  For Java Tips & Tricks, subscribe to the esus.com newsletter!
Search Java Q&A, Links, API's:   adv 

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)

This code sample is only viewable to esus.com members
Login or become a member!



3) Create the following directory structure:

This code sample is only viewable to esus.com members
Login or become a member!



4) Create the Java Servlet HelloWorldServlet.java and put the .class file in webapps\helloworld\WEB-INF\classes
HelloWorldServlet.java:

This code sample is only viewable to esus.com members
Login or become a member!



5) Create web.xml and put it in \webapps\helloworld\WEB-INF.
web.xml:

This code sample is only viewable to esus.com members
Login or become a member!



6) Modify server.xml that is located in \conf and have it include our Web Application using a new Context entry:

This code sample is only viewable to esus.com members
Login or become a member!



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.

This code sample is only viewable to esus.com members
Login or become a member!



8) Test the HelloWorldServet! Type in your web browser:

This code sample is only viewable to esus.com members
Login or become a member!




Further Information
Author of answer: Joris Van den Bogaert

Comments
Comments to this answer are only viewable by members. Login or become a member!





Terms of Service | Privacy Policy | Contact

Copyright © 2000-2003 Esus.com - All Rights Reserved 
Java and all Java-based trademarks are trademarks of Sun Microsystems, Inc. Esus.com is independent of Sun Microsystems, Inc. All other trademarks are the sole property of their respective owners.