Class GlobalHeadersFilter
- java.lang.Object
-
- com.microstrategy.web.filter.GlobalHeadersFilter
-
- All Implemented Interfaces:
javax.servlet.Filter
public class GlobalHeadersFilter extends java.lang.Object implements javax.servlet.FilterImplementation of Servlet filter that adds one or more headers to each and every HTTP response.The headers and their values are specified as a comma-separated list in the headerConfig parameter in the filter config. If a header value happens to have commas, specify it within quotes.
The headers will be added to every resource that matches the 'url-pattern' specified in the filter-mapping configuring the filter.
For example, the snippet from WEB.XML below will cause the following three headers
- X-XSS-Protection:1; mode=block
- Cache-Control: no-cache, no-store, must-revalidate
- X-Content-Type-Options:nosniff
<filter> <filter-name>GlobalHeaders</filter-name> <filter-class>com.microstrategy.web.filter.GlobalHeadersFilter</filter-class> <init-param> <param-name>headerConfig</param-name> <param-value> X-XSS-Protection:1; mode=block, "Cache-Control: no-cache, no-store, must-revalidate", X-Content-Type-Options:nosniff </param-value> </init-param> </filter> <filter-mapping> <filter-name>GlobalHeaders</filter-name> <url-pattern>*</url-pattern> </filter-mapping>The filter can be configured multiple times using different url-pattern to apply different headers to different file types
-
-
Constructor Summary
Constructors Constructor Description GlobalHeadersFilter()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voiddestroy()voiddoFilter(javax.servlet.ServletRequest request, javax.servlet.ServletResponse response, javax.servlet.FilterChain chain)Called once per HTTP request that matches the "url-pattern" as set in the servlet's configuration.voidinit(javax.servlet.FilterConfig cfg)Called once to initialize the filter.
-
-
-
Method Detail
-
doFilter
public void doFilter(javax.servlet.ServletRequest request, javax.servlet.ServletResponse response, javax.servlet.FilterChain chain) throws java.io.IOException, javax.servlet.ServletExceptionCalled once per HTTP request that matches the "url-pattern" as set in the servlet's configuration.- Specified by:
doFilterin interfacejavax.servlet.Filter- Throws:
java.io.IOExceptionjavax.servlet.ServletException- See Also:
Filter.doFilter(javax.servlet.ServletRequest, javax.servlet.ServletResponse, javax.servlet.FilterChain)
-
init
public void init(javax.servlet.FilterConfig cfg) throws javax.servlet.ServletExceptionCalled once to initialize the filter. Since only one instance is ever created the data loaded into member variables is shared across all HTTP requests. i.e. no need to make this stuff static.- Specified by:
initin interfacejavax.servlet.Filter- Throws:
javax.servlet.ServletException- See Also:
Filter.init(javax.servlet.FilterConfig)
-
destroy
public void destroy()
- Specified by:
destroyin interfacejavax.servlet.Filter
-
-