O'Reilly logo

JavaServer Faces by Hans Bergsten

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Web Application Deployment Descriptor

The WEB-INF/web.xml file is the Java web application deployment descriptor that contains all general configuration information for the application, in addition to the JSF-specific information in the WEB-INF/faces-config.xml file described in Appendix E. Some elements are especially important for a JSF application, namely the <context-param>, <servlet>, and <servlet-mapping> elements. See the subsections for these elements for what configurations you must and can set for a JSF-application in the WEB-INF/web.xml file.

The deployment descriptor is an XML file. Starting with Servlet 2.4 and JSP 2.0, the elements it can contain and how they must be arranged are controlled by a number of XML Schema documents. The main XML Schema document, which includes the others, is available online at http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd. This XML Schema document must be referenced in the root element of the deployment description, as shown in Example F-1.

Example F-1. Web Application Descriptor root element for Servlet 2.4/JSP 2.0
<web-app xmlns="http://java.sun.com/xml/ns/j2ee"
  xmlns:xsi="http://www.w3c.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>

If you’re not familiar with the intricate details of XML Schema and namespace declarations, just accept the fact that you must enclose all other elements in the deployment descriptor within a <web-app> ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required