Java Forum

Ask Question   UnAnswered
Home » Forum » Java       RSS Feeds

run JSP and servlet in TomCat

  Asked By: Harley    Date: Jul 31    Category: Java    Views: 1292

any buddy can teach me how to deploy the jsp and servlet in
tomcat environment.
because I cannot direct attach the jsp and clasees file the the

how to setting the web.xml file.



1 Answer Found

Answer #1    Answered By: Mamie Wallace     Answered On: Jul 31

The most common deployment for a web  app is using a war. However, if
you wnat to do it manually, you can create a directory tree under the
<tomcat_root>/webapps directory. Under this directory, you need
another directory called WEB-INF(all caps). This is where web.xml is
stored. deploy  your classes under WEB-INF/classes and libraries into

The web.xml is not too tricky. It is a basic xml file  with the normal
xml prolog and a DOCTYPE that indicates it is a webapp and a uri to
the dtd. Here is a sample:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Web
Application 2.3//EN" "http://java.sun.com/dtd/web-app_2_3.dtd">

The servlet  tag defines the servlet class with an alias. The mapping
is the url that specifies the url that will use that servlet. In this
case, it is /SampleServlet. There are quite a few more tags, but this
is a basic web.xml.

A war is all of the above with a manifest in a zip/jar renamed with
the .war extension. tomcat  can auto-deploy wars. Remember, your
web.xml and related classes go under the WEB-INF directory under the
webapp root.

Didn't find what you were looking for? Find more on run JSP and servlet in TomCat Or get search suggestion and latest updates.