public class

GlobalHeadersFilter

extends Object
implements Filter
java.lang.Object
   ↳ com.microstrategy.web.filter.GlobalHeadersFilter

Class Overview

Implementation 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
to be added as HTTP headers to all (*) responses.

<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

Summary

Public Constructors
GlobalHeadersFilter()
Public Methods
void destroy()
void doFilter(ServletRequest request, ServletResponse response, FilterChain chain)
Called once per HTTP request that matches the "url-pattern" as set in the servlet's configuration.
void init(FilterConfig cfg)
Called once to initialize the filter.
[Expand]
Inherited Methods
From class java.lang.Object
From interface javax.servlet.Filter

Public Constructors

public GlobalHeadersFilter ()

Public Methods

public void destroy ()

public void doFilter (ServletRequest request, ServletResponse response, FilterChain chain)

Called once per HTTP request that matches the "url-pattern" as set in the servlet's configuration.

Throws
IOException
ServletException

public void init (FilterConfig cfg)

Called 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.

Throws
ServletException