A web descriptor (web.xml
) is not a requirement in Java EE 7, but for a JSF application, we need to configure the Facelets servlet. To create a web descriptor, select File | New | Other.
In New, select JBoss Tools Web | Web Descriptor and click on Next, as shown in the following screenshot:
In the Web Descriptor File wizard for Folder, click on Browse to select a folder. In Folder Selection, select the WEB-INF folder and click on OK, as shown in the following screenshot:
Select the WEB-INF folder and specify Name as web.xml
, Version as 3.1
and click on Finish, as shown in the following screenshot:
A web.xml
file gets created in the WEB-INF
folder. In web.xml
, specify the Faces servlet and its servlet mappings. The web.xml
web descriptor is listed as follows:
<?xml version="1.0" encoding="UTF-8"?> <web-app version="3.1" xmlns="http://xmlns.jcp.org/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd"> <display-name>JSF 2.x Facelets</display-name> <servlet> <servlet-name>Faces Servlet</servlet-name> <servlet-class>javax.faces.webapp.FacesServlet</servlet-class> <load-on-startup>1</load-on-startup> </servlet> <servlet-mapping> <servlet-name>Faces Servlet</servlet-name> <url-pattern>*.jsf</url-pattern> </servlet-mapping> <servlet-mapping> <servlet-name>Faces Servlet</servlet-name> <url-pattern>*.faces</url-pattern> </servlet-mapping> <servlet-mapping> <servlet-name>Faces Servlet</servlet-name> <url-pattern>*.xhtml</url-pattern> </servlet-mapping> <servlet-mapping> <servlet-name>Faces Servlet</servlet-name> <url-pattern>/faces/*</url-pattern> </servlet-mapping> </web-app>
The web.xml
is shown in the following jboss-jsf2
web project: