Creating your first Tomcat application

Author: Neale Rudd, Metawerx

Date: 27-Sep-2006

This is a short tutorial on creating a new application on Tomcat.

It assumes the site is hosted with Metawerx, but will work elsewhere as long as you can find your webapps folder, have the Tomcat Manager installed, or can manually reset the JVM if necessary.

Create the folder structure for the application

First, locate your webapps folder, this will be referred to as <webapps> below

  • On a Metawerx Shared JVM this is located at /private-cgi-bin/tomcat
  • On a Metawerx Self-Managed JVM, or a fresh tomcat installation, this is located at <path you installed tomcat to>/webapps, eg: /cust/YOURNAME/home/webapps
  • We will call this folder <webapps> in the rest of this document

Create a folder under the <webapps> folder (eg: /private-cgi-bin/tomcat/MyNewApp)

Tip: if this will be your main application for the website, call the application 'ROOT' (in capitals) instead of MyNewApp, to make it the ROOT application for your site.

Create a WEB-INF folder in the new folder (eg: /private-cgi-bin/tomcat/MyNewApp/WEB-INF)

Your application folder structure should now look like this:


Creating your web.xml file

Create a new file in WEB-INF called web.xml, containing the following:

<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns=""

    <display-name>My First App</display-name>
    <description>This is my first application</description>


Your application structure should now look like this:


This file is the Deployment Descriptor. It describes the application to Tomcat.

As soon as Tomcat notices the <appname>/WEB-INF/web.xml file inside the webapps folder, it will deploy the application automatically, and it will appear in the Tomcat Manager using the name from the <display-name> tag above. This is handled automatically by Tomcat's autoDeploy feature.

We will add a welcome page to show the application is working.

Add a welcome page

Create a file called /tomcat/MyNewApp/index.jsp using the following content:

<h1>My First App</h1>
<p>This is an application running on Tomcat</p>

Your application structure should now look like this:



That's all there is to it! The application should have started automatically. This can be checked by browing to http://yoursite/MyNewApp.

You can also check the status of your new application Tomcat Manager.

  • Access the Tomcat Manager, using http://yoursite/manager/html
  • Look for your new application in the Applications list.
  • If it says true in the running column, your application is running successfully
  • If it says false, there is an error in your web.xml file, or the way you have created the folders. Check that your web.xml file contains the content from above.

If the application is not running, see Troubleshooting Application Deployment on Tomcat.


You can now add some JSP code to your index.jsp file, or make a new JSP file in the application root folder.

For Java Servlets, you will need to add some information in the web.xml file. This is covered in more detail at web.xml. See the <servlet> and <servlet-mapping> tags.

More Information

metawerx specific

referring pages