-
Available since OmniFaces 3.14
The MutableRequestFilter
will wrap the incoming HttpServletRequest
in a MutableRequestFilter.MutableRequest
so that the developer can mutate the headers and parameters in such way that the outcome of among others HttpServletRequest.getHeader(String)
and ServletRequest.getParameter(String)
are influenced.
Installation
To get this filter to run, map it as follows in web.xml
:
<filter>
<filter-name>mutableRequestFilter</filter-name>
<filter-class>org.omnifaces.filter.MutableRequestFilter</filter-class>
</filter>
<filter-mapping>
<filter-name>mutableRequestFilter</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
The ordering of the <filter-mapping>
is significant. The MutableRequestFilter.MutableRequest
is not available in any filter which is mapped before the MutableRequestFilter
.
Usage
When inside FacesContext
, use Faces.getMutableRequestHeaderMap()
or Faces.getMutableRequestParameterMap()
. Or when having only a HttpServletRequest
at hands, use Servlets.getMutableRequestHeaderMap(HttpServletRequest)
or Servlets.getMutableRequestParameterMap(HttpServletRequest)
.