Class HeaderFilter

  • All Implemented Interfaces:
    javax.servlet.Filter

    public class HeaderFilter
    extends IncludeExcludeBasedFilter
    Header Filter

    This filter sets or adds a header to the response.

    The headerConfig init param is a CSV of actions to perform on headers, with the following syntax:
    [action] [header name]: [header value]
    [action] can be one of set, add, setDate, or addDate
    The date actions will add the header value in milliseconds to the current system time before setting a date header.

    Below is an example value for headerConfig:

     set X-Frame-Options: DENY,
     "add Cache-Control: no-cache, no-store, must-revalidate",
     setDate Expires: 31540000000,
     addDate Date: 0
     
    See Also:
    IncludeExcludeBasedFilter
    • Constructor Summary

      Constructors 
      Constructor Description
      HeaderFilter()  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void doFilter​(javax.servlet.ServletRequest request, javax.servlet.ServletResponse response, javax.servlet.FilterChain chain)  
      void init​(javax.servlet.FilterConfig filterConfig)  
      java.lang.String toString()  
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
    • Constructor Detail

      • HeaderFilter

        public HeaderFilter()
    • Method Detail

      • init

        public void init​(javax.servlet.FilterConfig filterConfig)
                  throws javax.servlet.ServletException
        Specified by:
        init in interface javax.servlet.Filter
        Overrides:
        init in class IncludeExcludeBasedFilter
        Throws:
        javax.servlet.ServletException
      • doFilter

        public void doFilter​(javax.servlet.ServletRequest request,
                             javax.servlet.ServletResponse response,
                             javax.servlet.FilterChain chain)
                      throws java.io.IOException,
                             javax.servlet.ServletException
        Throws:
        java.io.IOException
        javax.servlet.ServletException