- All Implemented Interfaces:
Filter
The response wrapper is additionally make available as a request attribute, so it's always obtainable even if a following filter
wraps the response again. By default the response wrapper is in "pass-through" mode, meaning it will do no buffering. Anywhere during the
request it can be switched to buffer by setting its passThrough argument to false.
The next call to obtain the response's writer will then provide one that buffers. Do note that any existing writer that has been obtained
before passThrough was set to false and is used afterwards, will not automatically start buffering. Only newly obtained
writers will buffer from that point on.
If at the end of the request, when this filter resumes control again, the response is still buffering (passThrough is false)
its buffer will be automatically flushed to the underlying response. If however the buffer is not empty, but passThrough is true,
no such flushing will be done and it's assumed the application has taken care of this.
- Since:
- 1.2
- Author:
- Arjan Tijms
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final StringThe request attribute name under which the buffered response is stored. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoiddoFilter(HttpServletRequest request, HttpServletResponse response, HttpSession session, FilterChain chain) Filter the HTTP request.Methods inherited from class org.omnifaces.filter.HttpFilter
destroy, doFilter, getFilterConfig, getInitParameter, getServletContext, init, init
-
Field Details
-
BUFFERED_RESPONSE
The request attribute name under which the buffered response is stored.- See Also:
-
-
Constructor Details
-
OnDemandResponseBufferFilter
public OnDemandResponseBufferFilter()
-
-
Method Details
-
doFilter
public void doFilter(HttpServletRequest request, HttpServletResponse response, HttpSession session, FilterChain chain) throws ServletException, IOException Description copied from class:HttpFilterFilter the HTTP request. The session argument isnullif there is no session.- 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:
-