In JSF, FacesServlet acts as the front controller, is the conduit for all the requests, and also sends the response back to the client. This servlet is a subclass of javax.servlet.Servlet
.
A web browser client sends an HTTP request to the servlet container. If it is a Faces request, then the servlet container invokes the service()
method of FacesServlet. The method hands over the processing of the request to a member instance javax.faces.lifecycle.LifeCycle
object. The method also creates a FacesContext instance. The LifeCycle
instance is responsible for the processing of a request to all of the JSF phases described in Chapter 2, JavaServer Faces Lifecycle and the rendering of the response.
It is possible to change the path name of the resource lookup and contract folders as well by configuring the web XML deployment descriptor. The constants are defined in the javax.faces.application.ResourceHandler
class. The WEBAPP_RESOURCES_DIRECTORY_PARAM_NAME
string constant defines the resource directory property's name and WEBAPP_CONTRACTS_DIRECTORY_PARAM_NAME
defines the contract directory property.
We can redefine the JSF web application defaults with the following web.xml
settings:
<web-app xmlns="http://xmlns.jcp.org/xml/ns/javaee" ...> <servlet> <servlet-name>Faces Servlet</servlet-name> <servlet-class>javax.faces.webapp.FacesServlet</servlet-class> <init-param> <param-name>javax.faces.WEBAPP_RESOURCES_DIRECTORY</param-name> <param-value>/myresources</param-value> </init-param> <init-param> <param-name>javax.faces.WEBAPP_CONTRACTS_DIRECTORY</param-name> <param-value>/mycontracts</param-value> </init-param> </servlet> ... </web-app>
We can specify the initial parameters on the Faces servlet in overriding the default configuration.
The Faces servlet understands several other configuration parameters. Here is a table of the possible parameter names. These are prefixed with javax.faces
:
These settings are best configured in the web deployment descriptor file (web.xml
).