FacesServlet is a servlet that manages the request processing lifecycle for web applications that are utilizing JavaServer Faces to construct the user interface.
If the application is running in a Servlet 3.0 (and beyond) container, the runtime must provide
an implementation of the javax.servlet.ServletContainerInitializer interface that
declares the following classes in its javax.servlet.annotation.HandlesTypes annotation.
javax.faces.annotation.FacesConfigjavax.faces.application.ResourceDependenciesjavax.faces.application.ResourceDependencyjavax.faces.component.FacesComponentjavax.faces.component.UIComponentjavax.faces.convert.Converterjavax.faces.convert.FacesConverterjavax.faces.event.ListenerForjavax.faces.event.ListenersForjavax.faces.render.FacesBehaviorRendererjavax.faces.render.Rendererjavax.faces.validator.FacesValidatorjavax.faces.validator.Validator
This servlet must automatically be mapped if it is not explicitly mapped in
web.xml or web-fragment.xml and one or more of the following conditions
are true.
A faces-config.xml file is found in WEB-INF
A faces-config.xml file is found in the META-INF directory of a jar in
the application's classpath.
A filename ending in .faces-config.xml is found in the META-INF
directory of a jar in the application's classpath.
The javax.faces.CONFIG_FILES context param is declared in web.xml or
web-fragment.xml.
The Set of classes passed to the onStartup() method of the
ServletContainerInitializer implementation is not empty.
If the runtime determines that the servlet must be automatically mapped, it must be mapped to the
following <url-pattern> entries.
Note that the automatic mapping to *.xhtml can be disabled with the context param
DISABLE_FACESSERVLET_TO_XHTML_PARAM_NAME.
This class must be annotated with javax.servlet.annotation.MultipartConfig. This causes
the Servlet container in which the JSF implementation is running to correctly handle multipart
form data.
Some security considerations relating to this class
The topic of web application security is a cross-cutting concern and every aspect of the specification address it. However, as with any framework, the application developer needs to pay careful attention to security. Please consider these topics among the rest of the security concerns for the application. This is by no means a complete list of security concerns, and is no substitute for a thorough application level security review.
Prefix mappings and the
FacesServletIf the
FacesServletis mapped using a prefix<url-pattern>, such as<url-pattern>/faces/*</url-pattern>, something must be done to prevent access to the view source without its first being processed by theFacesServlet. One common approach is to apply a <security-constraint> to all facelet files and flow definition files. Please see the Deployment Descriptor chapter of the Java Servlet Specification for more information the use of <security-constraint>.Allowable HTTP Methods
The JSF specification only requires the use of the GET and POST http methods. If your web application does not require any other http methods, such as PUT and DELETE, please consider restricting the allowable http methods using the <http-method> and <http-method-omission> elements. Please see the Security of the Java Servlet Specification for more information the use of these elements.
| Modifier and Type | Class and Description |
|---|---|
| private static enum |
| Modifier and Type | Field and Description |
|---|---|
| private Set | |
| private boolean | |
| private static final String | ALLOWED_HTTP_METHODS_ATTR
A white space separated list of case sensitive HTTP method names that are allowed to be processed by this servlet. |
| private Set | |
| private Set | |
| public static final String | CONFIG_FILES_ATTR
Context initialization parameter name for a comma delimited list of context-relative resource
paths (in addition to |
| private final Set | |
| public static final String | DISABLE_FACESSERVLET_TO_XHTML_PARAM_NAME
The |
| private FacesContextFactory | facesContextFactory
Factory for |
| private boolean | initFacesContextReleased
From GLASSFISH-15632. |
| private Lifecycle | |
| public static final String | LIFECYCLE_ID_ATTR
Context initialization parameter name for the lifecycle identifier of the |
| private static final Logger | LOGGER
The |
| private ServletConfig | servletConfig
The |
| Access | Constructor and Description |
|---|---|
| public |
| Modifier and Type | Method and Description |
|---|---|
| private FacesContext | |
| private FacesContextFactory | |
| private Lifecycle | |
| public void | |
| private void | |
| public ServletConfig | getServletConfig()
Implements javax.
Return the |
| public String | getServletInfo()
Implements javax. Return information about this Servlet. |
| public void | init(ServletConfig
a servletConfig)ServletConfig object
containing the servlet's
configuration and initialization parametersImplements javax. Acquire the factory instances we will require. |
| private void | |
| private void | |
| public void | |
| private boolean | |
| private boolean | |
| private void | |
| private void | |
| private boolean | |
| private void | |
| private void | |
| private void | |
| public void | service(ServletRequest
The servlet request we are processing req, ServletResponse The servlet response we are creating resp)Implements javax. Process an incoming request, and create the corresponding response according to the following specification. |
| private void |
| allHttpMethods | back to summary |
|---|---|
| private Set<FacesServlet. | |
| allowAllMethods | back to summary |
|---|---|
| private boolean allowAllMethods | |
| ALLOWED_HTTP_METHODS_ATTR | back to summary |
|---|---|
| private static final String ALLOWED_HTTP_METHODS_ATTR A white space separated list of case sensitive HTTP method names that are allowed to be processed by this servlet. * means allow all | |
| allowedKnownHttpMethods | back to summary |
|---|---|
| private Set<FacesServlet. | |
| allowedUnknownHttpMethods | back to summary |
|---|---|
| private Set<String> allowedUnknownHttpMethods | |
| CONFIG_FILES_ATTR | back to summary |
|---|---|
| public static final String CONFIG_FILES_ATTR
Context initialization parameter name for a comma delimited list of context-relative resource
paths (in addition to | |
| defaultAllowedHttpMethods | back to summary |
|---|---|
| private final Set<FacesServlet. | |
| DISABLE_FACESSERVLET_TO_XHTML_PARAM_NAME | back to summary |
|---|---|
| public static final String DISABLE_FACESSERVLET_TO_XHTML_PARAM_NAME
The If this parameter is not specified, this automatic mapping is enabled as specified above. | |
| facesContextFactory | back to summary |
|---|---|
| private FacesContextFactory facesContextFactory
Factory for | |
| initFacesContextReleased | back to summary |
|---|---|
| private boolean initFacesContextReleased From GLASSFISH-15632. If true, the FacesContext instance left over from startup time has been released. | |
| lifecycle | back to summary |
|---|---|
| private Lifecycle lifecycle
The | |
| LIFECYCLE_ID_ATTR | back to summary |
|---|---|
| public static final String LIFECYCLE_ID_ATTR
Context initialization parameter name for the lifecycle identifier of the | |
| LOGGER | back to summary |
|---|---|
| private static final Logger LOGGER The | |
| servletConfig | back to summary |
|---|---|
| private ServletConfig servletConfig
The | |
| FacesServlet | back to summary |
|---|---|
| public FacesServlet() | |
| acquireFacesContext | back to summary |
|---|---|
| private FacesContext acquireFacesContext(HttpServletRequest request, HttpServletResponse response) | |
| acquireFacesContextFactory | back to summary |
|---|---|
| private FacesContextFactory acquireFacesContextFactory() throws UnavailableException | |
| acquireLifecycle | back to summary |
|---|---|
| private Lifecycle acquireLifecycle() throws ServletException | |
| destroy | back to summary |
|---|---|
| public void destroy() Implements javax. Release all resources acquired at startup time.
| |
| executeLifecyle | back to summary |
|---|---|
| private void executeLifecyle(FacesContext context) throws IOException, ServletException | |
| getServletConfig | back to summary |
|---|---|
| public ServletConfig getServletConfig() Implements javax.
Return the
| |
| getServletInfo | back to summary |
|---|---|
| public String getServletInfo() Implements javax. Return information about this Servlet.
| |
| init | back to summary |
|---|---|
| public void init(ServletConfig servletConfig) throws ServletException Implements javax. Acquire the factory instances we will require.
| |
| initHttpMethodValidityVerification | back to summary |
|---|---|
| private void initHttpMethodValidityVerification() | |
| initHttpMethodValidityVerificationWithCatch | back to summary |
|---|---|
| private void initHttpMethodValidityVerificationWithCatch() throws ServletException | |
| initializeAllowedKnownHttpMethods | back to summary |
|---|---|
| public void initializeAllowedKnownHttpMethods(List<String> allowedKnownHttpMethodsStringList) | |
| isHttpMethodValid | back to summary |
|---|---|
| private boolean isHttpMethodValid(HttpServletRequest request) | |
| isKnownHttpMethod | back to summary |
|---|---|
| private boolean isKnownHttpMethod(String httpMethod) | |
| logIfThreadInterruped | back to summary |
|---|---|
| private void logIfThreadInterruped() | |
| logUnknownHttpMethod | back to summary |
|---|---|
| private void logUnknownHttpMethod(String httpMethod) | |
| notProcessWebInfIfPrefixMapped | back to summary |
|---|---|
| private boolean notProcessWebInfIfPrefixMapped(HttpServletRequest request, HttpServletResponse response) throws IOException | |
| releaseFacesInitContextIfNeeded | back to summary |
|---|---|
| private void releaseFacesInitContextIfNeeded() | |
| requestEnd | back to summary |
|---|---|
| private void requestEnd() DO NOT REMOVE. Necessary for V3 probe monitoring. | |
| requestStart | back to summary |
|---|---|
| private void requestStart(String requestUri) DO NOT REMOVE. Necessary for V3 probe monitoring. | |
| service | back to summary |
|---|---|
| public void service(ServletRequest req, ServletResponse resp) throws IOException, ServletException Implements javax. Process an incoming request, and create the corresponding response according to the following specification.
If the
This method must respond to requests that contain
the following strings by invoking the
If none of the cases described above in the specification for this method apply to the servicing of this request, the following action must be taken to service the request.
Acquire a
Acquire the
The implementation must make it so
| |
| uninitHttpMethodValidityVerification | back to summary |
|---|---|
| private void uninitHttpMethodValidityVerification() | |
| Modifier and Type | Field and Description |
|---|---|
| public static final FacesServlet. | |
| public static final FacesServlet. | |
| public static final FacesServlet. | |
| public static final FacesServlet. | |
| private String | name
Hides java. |
| public static final FacesServlet. | |
| public static final FacesServlet. | |
| public static final FacesServlet. | |
| public static final FacesServlet. |
| Access | Constructor and Description |
|---|---|
| private |
| Modifier and Type | Method and Description |
|---|---|
| public String | toString()
Overrides java. |
| public static FacesServlet. | |
| public static FacesServlet. |
| CONNECT | back to summary |
|---|---|
| public static final FacesServlet. | |
| DELETE | back to summary |
|---|---|
| public static final FacesServlet. | |
| GET | back to summary |
|---|---|
| public static final FacesServlet. | |
| HEAD | back to summary |
|---|---|
| public static final FacesServlet. | |
| name | back to summary |
|---|---|
| private String name Hides java. | |
| OPTIONS | back to summary |
|---|---|
| public static final FacesServlet. | |
| POST | back to summary |
|---|---|
| public static final FacesServlet. | |
| PUT | back to summary |
|---|---|
| public static final FacesServlet. | |
| TRACE | back to summary |
|---|---|
| public static final FacesServlet. | |
| HttpMethod | back to summary |
|---|---|
| private HttpMethod(String name) | |
| toString | back to summary |
|---|---|
| public String toString() Overrides java. Doc from java. Returns the name of this enum constant, as contained in the declaration. This method may be overridden, though it typically isn't necessary or desirable. An enum class should override this method when a more "programmer-friendly" string form exists. | |
| valueOf | back to summary |
|---|---|
| public static FacesServlet. | |
| values | back to summary |
|---|---|
| public static FacesServlet. | |