Download
FAQ
History
PrevHomeNext API
Search
Feedback
Divider

Installing Web Applications

A context is a name that gets mapped to a Web application. For example, the context of the hello1 application is /hello1. To install an application into Tomcat, you notify Tomcat that a new context is available. An installed application is not available after Tomcat is restarted. To permanently deploy an application you invoke the manager application deploy command (see Deploying Web Applications). Installing an application is the recommended operation when you are iteratively developing an application because you do not have to package the WAR and because you can quickly reload a modified application.

You install an application into Tomcat with the manager application install command invoked via the Ant install task. The Ant install task tells the manager application running at the location specified by the url attribute to install an application at the context specified by the path attribute. In addition, you must indicate the location of the Web application files. There are two ways to do this:

To specify the directory path, you use the war attribute. The value of the war attribute can be a WAR file: jar:file:/path/to/bar.war!/ or an unpacked directory file:/path/to/foo.

<install url="url" path="mywebapp" war="file:${build}"
  username="username" password="password" /> 

The username and password attributes are discussed in Appendix B.

You can specify the location of the Web application files via a configuration file with the config attribute:

<install url="url" 
  path="mywebapp" config="file:context.xml"
  username="username" password="password"/> 

The configuration file contains a context entry of the form:

<Context path="/bookstore1"
  docBase="../../jwstutorial13/examples/web/bookstore1/build"
  debug="0"> 

The format of a context entry is described in the Server Configuration Reference at http://jakarta.apache.org/tomcat/tomcat-5.0-doc/config/context.html. The context entry specifies the location of the Web application files through its docBase attribute.


Note: The setting of the docBase attribute in the tutorial examples contains a path to the example build directory that's defined relative to the <JWSDP_HOME>/webapps/ directory:

../../jwstutorial13/examples/web/bookstore1/build/

This setting assumes that you have installed the tutorial in the same directory as the Java WSDP. If you install the tutorial in another directory, you will need to adjust the docBase attribute so that it reflects the path between the webapps directory and the example build directory. For example, if you install the tutorial in the Java WSDP install directory, the docBase attribute should be changed to ../jwstutorial13/examples/web/bookstore1/build/.


The tutorial example build files contain Ant install and install-config targets that invoke the Ant install task:

<target name="install" 
  description="Install web application" depends="build">
  <install url="${url}" path="${mywebapp}"
    war="file:${build}"
    username="${username}" password="${password}"/>
</target> 
<target name="install-config" 
  description="Install web application" depends="build">
  <install url="${url}" path="${mywebapp}"
    config="file:{example.path}/context.xml"
    username="${username}" password="${password}"/>
</target> 

To install the hello1 application described in Web Application Life Cycle:

  1. In a terminal window, go to <INSTALL>/jwstutorial13/examples/web/hello1/.
  2. Make sure Tomcat is started.
  3. Execute ant install. The install target notifies Tomcat that the new context is available.
Divider
Download
FAQ
History
PrevHomeNext API
Search
Feedback
Divider

All of the material in The Java(TM) Web Services Tutorial is copyright-protected and may not be published in other works without express written permission from Sun Microsystems.