Home TOC |
![]() ![]() ![]() |
Installing Web Applications
A context is a name that gets mapped to the document root of a Web application. The context of the
Hello1
application is /hello1
. The request URLhttp://localhost:8080/hello1/index.html
retrieves the fileindex.html
from the document root. To install an application to Tomcat, you notify Tomcat that a new context is available.You notify Tomcat of a new context with the
Ant
install
task. TheAnt
install
task does not require Tomcat to be restarted, but an installed application is also not remembered after Tomcat is restarted. To permanently deploy an application, see Deploying Web Applications.The
Ant
install
task tells a Tomcat manager application running at the location specified by theurl
attribute to install an application at the context specified by thepath
attribute and the location containing the Web application files specified with thewar
attribute. The value of thewar
attribute can be a WAR filejar:file:/path/to/bar.war!/
or an unpacked directoryfile:/path/to/foo
.<install url="url" path="path" war="file:build" username="username" password="password" />The
username
andpassword
attributes are discussed in Managing the Examples.Instead of providing a
war
attribute, you can specify configuration information with theconfig
attribute:<install url="url" path="path" config="file:build/example.xml" username="username" password="password"/>The
config
attribute points to a configuration file that contains a context entry of the form:<Context path="/bookstore1" docBase="../docs/tutorial/examples/web/bookstore1/build" debug="0">Note that the context entry implicitly specifies the location of the Web application files through its
docBase
attribute.The tutorial example build files contain an
Ant
install
target that invokes theAnt
install
task:<target name="install" description="Install web application" depends="build"> <install url="${url}" path="${path}" war="file:${build}" username="${username}" password="${password}"/> </target>The
Ant
install
task requires that a Web application deployment descriptor (web.xml
) be available. All the example applications are distributed with a deployment descriptor.To install the
Hello1
application described in Web Application Life Cycle
Home TOC |
![]() ![]() ![]() |