Home TOC |
![]() ![]() ![]() |
Deploying Web Applications
The next step after you have programmed and configured a Web application is to deploy it to Tomcat. You deploy an application to Tomcat by notifying it of a new application context. The first time you deploy a new application you must restart Tomcat. Thereafter you can reload the application as described in Reloading the Examples.
Specifying the Web Application Context
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.Tomcat can be notified of a new context in two ways:
- Automatically. If you copy a Web application directory or WAR to
<
JWSDP_HOME
>/webapps
, the context root for the application is automatically added to the Tomcat configuration. This is the approach used by the simpler applications (Hello1
,Hello2
,Date
) discussed in the Web technology chapters.- By adding a context entry to Tomcat's configuration. This is the approach used by the Duke's Bookstore application discussed in the Web technology chapters. For example, here is the
Context
entry for the application discussed in JavaServlet Technology (page 393):
<Context path="/bookstore1" docBase="../docs/tutorial/examples/web/bookstore1/build" debug="0">
- There are two ways to add this entry to Tomcat's configuration:
- Edit the file
<
JWSDP_HOME
>/conf/server.xml
. Since this can be error prone, we recommend the next approach.- Put an application-specific configuration file in
<
JWSDP_HOME
>/webapps
. TheContext
entry for the application discussed in JavaServlet Technology (page 393) is in the file
docs/tutorial/web/bookstore1/bookstore.xml
. When the application is deployed,bookstore1.xml
is copied to<
JWSDP_HOME
>/webapps
.
Note: Manual specification of theContext
entry is a limitation of the current release of the Web Services Pack. Later releases will include an administration tool that will simplify this task.
Example
To deploy the
Hello1
application:
- Go to
docs/tutorial/examples/hello1
and build and deploy the example by runningant
. This runs the default ant targetdeploy
which depends on thebuild
target. Thebuild
target will spawn any necessary compilations and copy files to thedocs/tutorial/examples/web/date/build
directory. Thedeploy
target copies the build directory to<JWSDP_HOME>
/webapps
.- Start or restart Tomcat.
Home TOC |
![]() ![]() ![]() |