Download
FAQ
History
HomeHomeNext API
Search
Feedback
Divider

Web Applications

Web components and static Web content files such as images are called Web resources. A Web application is the smallest deployable and usable unit of Web resources.

Web applications are typically packaged and deployed as Web archive (WAR) files. The format of a WAR file is identical to that of a JAR file. However, the contents and use of WAR files differ from JAR files, so WAR file names use a .war extension.

In addition to Web components and Web resources, a Web application can contain other files including:

The top-level directory of a Web application 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:

You can also create application-specific subdirectories (that is, package directories) in either the document root or the /WEB-INF/classes/ directory.

The WAR structure just described is portable; you can install it into any container that conforms to the Java Servlet Specification.

Packaging a Web Application

You package Web application into a WAR by executing the jar command in a directory laid out in the format of a Web module or by using the Ant war task. This tutorial uses the latter approach. To build and package the hello1 application into a WAR named hello1.war:

  1. In a terminal window, go to <INSTALL>/jwstutorial12/examples/web/hello1/.
  2. Run ant build. This target will spawn any necessary compilations and copy files to the <INSTALL>/jwstutorial12/examples/web/hello1/build/ directory.
  3. Run ant package. This target creates a WAR in the directory <INSTALL>/jwstutorial12/examples/web/hello1/dist/.

A sample hello1.war is provided in <INSTALL>/jwstutorial12/examples/web/provided-wars/.

Divider
Download
FAQ
History
HomeHomeNext 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.