|
FAQ
History |
|
Search
Feedback |
Web Application Archives
If you want to distribute a Web application, you package it in a Web application archive (WAR), which is a JAR similar to the package used for Java class libraries. In addition to Web components, a Web application archive can contain other files including the following:
Web components and static Web content files are called Web resources.
A Web application can run from a WAR file or from an unpacked directory laid out in the same format as a WAR.
WAR Directory Structure
The top-level directory of a WAR is the document root of the application. The document root is where JSP pages, client-side classes and archives, and static Web resources are stored.
The document root contains a subdirectory called
WEB-INF, which contains the following files and directories:
web.xml -The Web application deployment descriptor- Tag library descriptor files (see Tag Library Descriptors)
classes- A directory that contains server-side classes: servlets, utility classes, and JavaBeans componentslib- A directory that contains JAR archives of libraries (tag libraries and any utility libraries called by server-side classes)You can also create application-specific subdirectories (that is, package directories) in either the document root or the
WEB-INF/classesdirectory.Tutorial Example Directory Structure
To facilitate iterative development and keep Web application source separate from compiled files, the source code for the tutorial examples is stored in the following structure under each application directory
mywebapp:The
Antbuild files (build.xml) distributed with the examples contain targets to create an unpacked WAR structure in thebuildsubdirectory ofmywebapp, copy and compile files into that directory, and invoke themanager(see Tomcat Web Application Manager) commands via specialAnttasks to install, reload, remove, deploy, and undeploy applications. The tutorial exampleAnttargets are:
prepare- Createsbuilddirectory and WAR subdirectories.build- Compiles and copies themywebappWeb application files into thebuilddirectory.install- Notifies Tomcat to install an application (see Installing Web Applications) using theAntinstalltask.reload- Notifies Tomcat to reload the application (see Updating Web Applications) using theAntreloadtask.- deploy - Notifies Tomcat to deploy the application (see Deploying Web Applications) using the
Antdeploytask.- undeploy - Notifies Tomcat to undeploy the application (see Undeploying Web Applications) using the
Antundeploytask.remove- Notifies Tomcat to remove the application (see Removing Web Applications) using theAntremovetask.Creating a WAR
You can manually create a WAR file in two ways:
Both of these methods require you to have created a Web application deployment descriptor.
|
FAQ
History |
|
Search
Feedback |
All of the material in The Java Web Services Tutorial is copyright-protected and may not be published in other works without express written permission from Sun Microsystems.