title: Servlet Filter: How to get all the headers from servletRequest?
body: <p>Here is how my <code>WebFilter</code> looks like  </p>
  
  <pre><code>@WebFilter("/rest/*")
  public class AuthTokenValidatorFilter implements Filter {
  
      @Override
      public void init(final FilterConfig filterConfig) throws ServletException {
      }
  
      @Override
      public void doFilter(final ServletRequest servletRequest, final ServletResponse servletResponse, final FilterChain filterChain) throws IOException, ServletException {
          final Enumeration&lt;String&gt; attributeNames = servletRequest.getAttributeNames();
          while (attributeNames.hasMoreElements()) {
              System.out.println("{attribute} " + servletRequest.getParameter(attributeNames.nextElement()));
          }
  
          final Enumeration&lt;String&gt; parameterNames = servletRequest.getParameterNames();
          while (parameterNames.hasMoreElements()) {
              System.out.println("{parameter} " + servletRequest.getParameter(parameterNames.nextElement()));
          }
          filterChain.doFilter(servletRequest, servletResponse);
      }
  
      @Override
      public void destroy() {
      }
  }
  </code></pre>
  
  <p>I tried to find out online as to how to get values for <code>HTTP headers</code> coming from request.  </p>
  
  <p>I did not find anything, so I tried to enumerate on <code>servletRequest.getAttributeNames()</code> and <code>servletRequest.getParameterNames()</code> without knowing anything, but I do not get any headers.</p>
  
  <p><strong>Question</strong><br>
  How can I get all the headers coming from the request?</p>