Developing Applications with Tomcat


The Actual Development Process

The following sections highlight the commands and tasks that you, as the developer of the code, will perform. The same basic approach works when you have multiple programmers involved, as long as you have an appropriate source code control system and internal team rules about who is working on what parts of the application at any given time.

Create Project Source Directory

The first step is to create a new project source directory, and customize the build.xml and build script you will be using. The directory structure is described in the section labeled Source Organization, or you can use the sample application located in doc/appdev as a starting point.


Configure Tomcat to Recognize Your Application

In order for Tomcat to recognize your application, you must integrate it as described in the section labeled Integration with Tomcat. Any of the proposed techniques can be used. For our purposes, we will assume that you are using the first approach (unpacked hierarchy), because we set the deployment home to be an appropriate directory under the %TOMCAT_HOME%/webapps directory.


Editing the Source and Building the Web Application

One may make changes to any of the source files (java, html, scripts, etc) and once saved we are ready to build our web application. We compile the application by issuing the build command from the project source root directory. The Ant tool will be utilized to compile any new or updated Java code.

We do this once we have ensured that the following variables have been set:

And the following have been done.




Test Your Web Application

To test your application, you will want to execute it under Tomcat. Assuming you have integrated your application as described earlier, this is very simple. Under Windows, execute:

    %TOMCAT_HOME%\bin\startup

This command starts Tomcat as a background process. Now, point your web browser at the home page for your application, by opening the following URL (where "/myapp" is the context path you have assigned to it):

    http://localhost:8080/myapp

Now, you can test your application to verify that it operates correctly. When you discover something that needs to change, fix it as follows:

Do not forget to commit your changes to the source code repository when you have completed your testing!


Deploy Your Web Application

When you are through adding new functionality, and you've tested everything, it is time to create the distributable version of your web application that can be deployed on the production server. The following general steps are required:



NB. The batch files found in %TOMCAT_HOME%\bin have been written and tested under Windows NT. Some modifications may be necessary for operation on a Windows 98 platform.


Previous    Next