HTML and CSS Reference
In-Depth Information
<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>/faces/*</url-pattern>
</servlet-mapping>
<session-config>
<session-timeout>
30
</session-timeout>
</session-config>
<welcome-file-list>
<welcome-file>faces/index.xhtml</welcome-file>
</welcome-file-list>
</web-app>
In Listing 1-1, there are two main things you need to know: the first one is the definition of the
Faces Servlet
and its
mapping to the (
/faces/*
) URL using the
<url-pattern>
element. The second one is the
javax.faces.PROJECT_STAGE
context parameter, which is set to
Development
(other possible values are
Production
,
SystemTest
, and
UnitTest
).
Setting the project stage in the development mode makes the JSF framework generate additional messages in the page
when finding a common development mistake. This feature can help the JSF developers to become more productive
during the development time.
Finally, the
<welcome-file>
element specifies the welcome page of the application, which is the
index.xhtml
file; this will make any request to
http://localhost:8080/firstApplication/
redirected to
http://localhost:8080/firstApplication/faces/index.xhtml
, which will trigger the
Faces Servlet
to prepare
the JSF context before going to the
index.xhtml
page.
■
In any Servlet 3.0 container such as GlassFish v3, the
web.xml
file is optional. If the web.xml is omitted, the
Faces Servlet will be automatically mapped to
*.jsf
,
*.faces
, and
/faces/*
urL patterns.
Note
Now, let's move to the
faces-config
file, which includes the related JSF configuration. Actually, since JSF 2.0, the
faces-config
file becomes optional because most of the JSF configuration can be defined using the Java annotations.
Listing 1-2 shows the
firstApplication
Faces configuration file.
Listing 1-2.
The firstApplication Faces Configuration File
<faces-config version="2.1"
xmlns="
http://java.sun.com/xml/ns/javaee
"
xmlns:xsi="
http://www.w3.org/2001/XMLSchema-instance
"
xsi:schemaLocation="
http://java.sun.com/xml/ns/javaee
