Class MutableRequestFilter
- java.lang.Object
 - 
- org.omnifaces.filter.HttpFilter
 - 
- org.omnifaces.filter.MutableRequestFilter
 
 
 
- 
- All Implemented Interfaces:
 Filter
public class MutableRequestFilter extends HttpFilter
The
MutableRequestFilterwill wrap the incomingHttpServletRequestin aMutableRequestFilter.MutableRequestso that the developer can mutate the headers and parameters in such way that the outcome of among othersHttpServletRequest.getHeader(String)andServletRequest.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. TheMutableRequestFilter.MutableRequestis not available in any filter which is mapped before theMutableRequestFilter.Usage
When inside
FacesContext, useFaces.getMutableRequestHeaderMap()orFaces.getMutableRequestParameterMap(). Or when having only aHttpServletRequestat hands, useServlets.getMutableRequestHeaderMap(HttpServletRequest)orServlets.getMutableRequestParameterMap(HttpServletRequest).- Since:
 - 3.14
 - Author:
 - Bauke Scholtz
 - See Also:
 HttpFilter,MutableRequestFilter.MutableRequest
 
- 
- 
Nested Class Summary
Nested Classes Modifier and Type Class Description static classMutableRequestFilter.MutableRequest 
- 
Field Summary
Fields Modifier and Type Field Description static StringMUTABLE_REQUESTThe name of the request attribute under which theMutableRequestFilter.MutableRequestwill be stored. 
- 
Constructor Summary
Constructors Constructor Description MutableRequestFilter() 
- 
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voiddoFilter(HttpServletRequest request, HttpServletResponse response, HttpSession session, FilterChain chain)Creates and sets the mutable request.static MutableRequestFilter.MutableRequestgetMutableRequest(HttpServletRequest request)Returns the mutable request.voidinit()Tracks whether this filter is installed.- 
Methods inherited from class org.omnifaces.filter.HttpFilter
destroy, doFilter, getFilterConfig, getInitParameter, getServletContext, init 
 - 
 
 - 
 
- 
- 
Field Detail
- 
MUTABLE_REQUEST
public static final String MUTABLE_REQUEST
The name of the request attribute under which theMutableRequestFilter.MutableRequestwill be stored.- See Also:
 - Constant Field Values
 
 
 - 
 
- 
Method Detail
- 
init
public void init() throws ServletExceptionTracks whether this filter is installed.- Overrides:
 initin classHttpFilter- Throws:
 ServletException- When filter's initialization failed.
 
- 
doFilter
public void doFilter(HttpServletRequest request, HttpServletResponse response, HttpSession session, FilterChain chain) throws ServletException, IOException
Creates and sets the mutable request.- Specified by:
 doFilterin classHttpFilter- Parameters:
 request- The HTTP request.response- The HTTP response.session- The HTTP session, if any, elsenull.chain- The filter chain to continue.- Throws:
 ServletException- As wrapper exception when something fails in the request processing.IOException- Whenever something fails at I/O level.- See Also:
 Filter.doFilter(ServletRequest, ServletResponse, FilterChain)
 
- 
getMutableRequest
public static MutableRequestFilter.MutableRequest getMutableRequest(HttpServletRequest request)
Returns the mutable request.- Returns:
 - The mutable request.
 - Throws:
 IllegalStateException- When theMutableRequestFilteris not installed or not invoked yet.- Since:
 - 3.14
 
 
 - 
 
 -