Packaging the Application as a WAR File

Packaging your web applications using the WAR format is very convenient. The structure is precise, and because it is specified so carefully, porting your applications across the various web containers is much easier. The next section describes the steps that you must perform to package your web application as a WAR file.

Creating the WAR File

The first step in packaging your application as a WAR file is to create a root directory. In most cases, this directory will have the same name as your web application. For our example, we will create a directory called storefront.

After deciding how your JSP and HTML pages will be placed within your application, place them underneath the root directory in their appropriate subdirectories. For the Storefront example, our directory structure so far would look like Figure 16-2.

The Storefront application directory structure

Figure 16-2. The Storefront application directory structure

Figure 16-2 shows 11 subdirectories, 8 of which contain JSP pages for the application. The images directory contains images that are used globally throughout the application, the stylesheets directory stores cascading stylesheets for the application, and the include directory contains files that are included using either a static or dynamic include.

The next step in setting up the WAR file is to ensure that you have a WEB-INF directory underneath your root web application ...

Get Programming Jakarta Struts now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.