13.1. Deploying an Application Automatically
Problem
You want to be able to test and retest your web application in Tomcat without having to redeploy the application whenever a change is made to a Java class or JSP page.
Solution
Use the development directories of your application as the actual
directories that the application server uses for the deployed
application. For Tomcat, you would create a
Context element immediately before the
</Host> end tag in the
conf/server.xml file (under your
CATALINA_HOME top-level directory).
<Host...>
...
<Context path="/struts-cookbook"
docBase="/path/to/myapp/web"
reloadable="true"/>
</Host>Discussion
This recipe is not particular to Struts but is applicable to any J2EE-based web applications. However, the Solution is particular to Tomcat. If you aren't using Tomcat, your application server most likely uses a similar mechanism. If you use the Solution, you won't have to deploy your application when changes are made; your application will always be deployed.
The docBase attribute specifies a file path to
your deployment directory. If you're using Windows,
you'll need to include the drive letter on the path
as shown here:
docBase="c:/Documents and Settings/My App/web"
The structure of this directory must match the structure of a valid J2EE web application. Its contents would look something like this:
/index.html /welcome.jsp /feedback.jsp /images/banner.gif /WEB-INF/web.xml /WEB-INF/struts-config.xml /WEB-INF/classes/ApplicationResources.properties /WEB-INF/classes/com/foo/MyBar.class ...