Main Content

What does a web application look like under Tomcat?

Archive - Originally posted on "The Horse's Mouth" - 2010-02-20 08:38:53 - Graham Ellis

When you're deploying a Java application on your web server, you're likely to be using a container engine such as Tomcat ([learn about tomcat]). If you're not the author of the application, it will probably come to you in a file with a .war extension - a Web ARchive file. A .war file contains loads of other files, compressed, for distribution and in development mode your Tomcat server will unpack it automatically for you. The layout of the files with the .war should be such that it will attach to Tomcat like a jigsaw puzzle piece and just run.


Once your .war in unpacked, you'll see a whole web application structure is revealed on the file system, as shown here. Within the application folder are your 'regular' web site files - your .html pages, and images, and so on - also style sheets and more. And there's a directory called WEB-INF which is not directly served, but which contains all the extra bits needed ...

The web.xml file is the configuration data for your application - there's an application name, and details of which java classes may to which URLs to provide your servlets.

The classes directory contains the classes that are servlets, and also other classes which are used within those servlets, or within Java Server Pages. With an application that you're not developing yourself, these classes will be in a compiled (.class) format and you won't be able to change the programming that they contain ... if you've got the source code, you can compile it up elsewhere and then replace those class files with two cautions - firstly, you'll need the servlet classes from Tomcat at compile time, and secondly please REMEMBER that Tomcat is a caching application container and if you change a class file you'll need to restart the web application for the modified file to be taken into account.


If you're a regular reader here, you'll guess I was teaching Tomcat deployment yesterday. If you're not a 'regular', you might like to know that we run a regular Apache httpd and Tomcat deployment training course on which we welcome delegates from a wide variety of companies and other organizations ;-)