Chapter 11. Web Applications (WARs) [DRAFT (1.0)]

Table of Contents

11.1. Creating a Web Application WAR
11.1.1. web.xml Format
11.2. The Web App Geronimo Deployment Plan
11.3. Structure of the Deployment Plan
11.3.1. Customizing the Web Application Class Path
11.3.2. Basic Web Application Settings
11.3.3. Web Container-specific Configuration
11.3.4. Resolving References
11.3.5. Security Settings
11.3.6. Adding Module-Scoped Services
11.4. Web Application Login
11.5. Forcing Web Application Deployment to Tomcat or Jetty

Geronimo supports Servlet 2.4 / JSP 2.0 web applications, with backward compatibility for previous spec versions. Web applications have full access to application components and resources deployed at the application or server level, and may deploy custom resources at the module level as well.

[Note]Note

Geronimo currently supports two web containers: Jetty and Tomcat. Each installation package supports one container or the other. The procedures and deployment plans in this chapter apply to both containers.

Deploying Web Applications to Geronimo typically involves several steps:

  1. Create the servlet classes, servlet filter classes, JSPs, and/or static content such as images, HTML, CSS, and JavaScript files.

  2. Create the standard web.xml deployment descriptor

  3. Create a Geronimo-specific geronimo-web.xml deployment plan

  4. Package the web application and deployment descriptors into a WAR file, or a directory tree laid out like a WAR

  5. Use the deployment tool described in Section 10.4, “The Deploy Tool” to deploy the WAR (or an EAR containing the WAR) into the server

The process of developing web applications and the standard web.xml deployment descriptor should be familiar already. After a brief review of what Geronimo expects from a WAR, this chapter focuses mainly on the contents of the Geronimo geronimo-web.xml deployment plan. This plan may be packaged within the web application WAR, or provided as a separate file in the EAR or to the deployment tool.

11.1. Creating a Web Application WAR

Geronimo doesn't have any special requirements on WAR files -- any WAR produced according to the standard J2EE process should work in Geronimo. However, there are a couple points to note:

  • Geronimo requires that every WAR file has a standard WEB-INF/web.xml deployment descriptor. This may be configured for Web App 2.2, Web App 2.3, or Web App 2.4, and should follow the appropriate XML format (see below).

  • If the WAR file is included in an application EAR, then the classes in the WAR will be able to access the classes in EJB JARs and J2EE Connector RARs in the EAR. Additionally, any classes in WEB-INF/classes and libraries in WEB-INF/lib will be included in the class path. Beyond that, external libraries can also be placed in the Geronimo server repository and referenced with dependency elements in the Geronimo deployment plan (see Section 11.3.1, “Customizing the Web Application Class Path”).

11.1.1. web.xml Format

Geronimo expects the WEB-INF/web.xml file to obey one of the following standard formats:

Web App 2.2

Defined by the DTD at http://java.sun.com/j2ee/dtds/web-app_2_2.dtd, a Web App 2.2 deployment descriptor looks like this:

<?xml version="1.0" encoding="UTF-8"?>

<!DOCTYPE web-app PUBLIC
    "-//Sun Microsystems, Inc.//DTD Web Application 2.2//EN"
    "http://java.sun.com/j2ee/dtds/web-app_2_2.dtd">

<web-app>
  ...
</web-app>
Web App 2.3

Defined by the DTD at http://java.sun.com/dtd/web-app_2_3.dtd, a Web App 2.3 deployment descriptor looks like this:

<?xml version="1.0" encoding="UTF-8"?>

<!DOCTYPE web-app PUBLIC
    "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
    "http://java.sun.com/dtd/web-app_2_3.dtd">

<web-app>
  ...
</web-app>
Web App 2.4

Defined by the XML schema at http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd, a Web App 2.4 deployment descriptor looks like this:

<?xml version="1.0" encoding="UTF-8"?>

<web-app xmlns="http://java.sun.com/xml/ns/j2ee"
        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee
            http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd"
        version="2.4">
  ...
</web-app>