Sample Tomcat application


Tomcat is the servlet container that is used in the official Reference Implementation for the Java Servlet and JavaServer Pages technologies. The Java Servlet and JavaServer Pages specifications are developed by Sun under the Java Community Process.

We want to add a custom application to Tomcat called article. The first thing we have to do is edit the file conf/server.xml

<Context path="/article" docBase="article" debug="0" reloadable="true" />

Now we have to make sone directories for our application.

mkdir webapps/article
mkdir webapps/article/WEB-INF
mkdir webapps/article/WEB-INF/classes
mkdir webapps/article/WEB-INF/lib

All *.html and *.jsp go into the directory webapps/article. All *.class files specific to our application go into webapps/article/WEB-INF/classes. All *.class files that are libraries to our application *.class files (typically *.jar files) go into webapps/article/WEB-INF/lib.

Assume we want to have a servlet that writes articles. Now we have to create the file webapps/article/WEB-INF/web.xml.


Now we have to create the file webapps/article/WEB-INF/classes/ and compile it. After restarting Tomcat, we can access the servlet from http://servername:8080/article/writer.

This entry was posted in programming and tagged , . Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s