Faces uses two configuration files: a web.xml file and a faces-config.xml file. Examples of both are shown below with comments on key or unusual features.
web.xml
This example shows the web.xml file basically as it is generated by the facesIDE plugin. You should note, however, that when your Faces application is deployed to a server that also includes one or more Struts applications, such as the wwwj server, you will need to combine the contents of their respective web.xml files into a single file. In doing so, you will need to update several of the tags in the combined file. These changes will be discussed in the segment dealing with deployment.
<?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"> <display-name>MyFaces Application</display-name> <!-- servlet --> <servlet> <servlet-name>FacesServlet</servlet-name> <servlet-class>javax.faces.webapp.FacesServlet</servlet-class> <load-on-startup>1</load-on-startup> </servlet> <!-- servlet-mapping --> <servlet-mapping> <servlet-name>FacesServlet</servlet-name> <url-pattern>*.jsf</url-pattern> </servlet-mapping> <!-- The Usual Welcome File List --> <welcome-file-list> <welcome-file>index.jsp</welcome-file> <welcome-file>index.html</welcome-file> </welcome-file-list> </web-app>
faces-config.xml
<?xml version="1.0"?> <!DOCTYPE faces-config PUBLIC "-//Sun Microsystems, Inc.//DTD JavaServer Faces Config 1.1//EN" "http://java.sun.com/dtd/web-facesconfig_1_1.dtd"> <faces-config> <managed-bean> <managed-bean-name>managedBeanUser</managed-bean-name> <managed-bean-class>jbs.eb2cuser.control.ManagedBeanUser</managed-bean-class> <managed-bean-scope>request</managed-bean-scope> </managed-bean> <!-- similar managed beans omitted --> <navigation-rule> <display-name>view/eb2cuser/register</display-name> <from-view-id>/view/eb2cuser/register.jsp</from-view-id> <navigation-case> <from-outcome>registerFailure</from-outcome> <to-view-id>/view/eb2cuser/register.jsp</to-view-id> </navigation-case> <navigation-case> <from-outcome>registerSuccess</from-outcome> <to-view-id>/view/eb2cuser/framesetHome.jsp</to-view-id> </navigation-case> </navigation-rule> <navigation-rule> <display-name>view/eb2cuser/login</display-name> <from-view-id>/view/eb2cuser/login.jsp</from-view-id> <navigation-case> <from-outcome>loginFailure</from-outcome> <to-view-id>/view/eb2cuser/login.jsp</to-view-id> </navigation-case> <navigation-case> <from-outcome>loginSuccess</from-outcome> <to-view-id>/view/eb2cuser/framesetHome.jsp</to-view-id> </navigation-case> </navigation-rule> <!-- similar navigation rules omitted --> </faces-config>