title: Filter order and web.xml content
body: <p>Well, straight to the point:
  i created - with Eclipse - two filters (Filter1 and Filter2) and a servlet(DisplayHeader) to see the filter order of execution.
  I used Tomcat 8.5 as target runtime.</p>
  
  <p>New/Dynamic Web Project/
      with Context root /
      and checked the "Generate web.xml delpoyment descriptor"</p>
  
  <p>Filter1 prints "I'm Filter 1" when  it's executed, and i "linked" it to a specific servlet "DisplayHeader".
  Filter2 it's the twin brother with 2 instead of 1.
  DisplayHeader servlet is mapped to /DisplayHeader.</p>
  
  <p>Below is Filter1 code for clarity</p>
  
  <pre><code>import java.io.IOException;
  import javax.servlet.*;
  import javax.servlet.annotation.WebFilter;
  
  @WebFilter(
          urlPatterns = {"/Filter1"}, 
          servletNames = {"DisplayHeader"}
          )
  public class Filter1 implements Filter {
  
      /**
       * Default constructor. 
       */
      public Filter1() {
          // TODO Auto-generated constructor stub
      }
  
      /**
       * @see Filter#destroy()
       */
      public void destroy() {
          // TODO Auto-generated method stub
      }
  
      /**
       * @see Filter#doFilter(ServletRequest, ServletResponse, FilterChain)
       */
      public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException {
          // TODO Auto-generated method stub
          // place your code here
          System.out.println("I'm Filter 1");
  
          // pass the request along the filter chain
          chain.doFilter(request, response);
      }
  
      /**
       * @see Filter#init(FilterConfig)
       */
      public void init(FilterConfig fConfig) throws ServletException {
          // TODO Auto-generated method stub
      }
  
  }
  </code></pre>
  
  <p>Well, when i run the servlet on Tomcat (Tomcat v8.5) it prints</p>
  
  <pre><code>I'm Filter 1
  I'm Filter 2
  </code></pre>
  
  <p>which means that Filter1 is executed before Filter2.</p>
  
  <p>I read that filter's order of execution comes from the mapping order in the web.xml file,
  so i expected to find somewhere in the web.xml file something like</p>
  
  <pre><code>&lt;filter-mapping&gt;
  &lt;filter-name&gt;Filter1&lt;/filter-name&gt;
  &lt;url-pattern&gt;/DisplayHeader&lt;/url-pattern&gt;
  &lt;/filter-mapping&gt;
  
  &lt;filter-mapping&gt;
  &lt;filter-name&gt;Filter2&lt;/filter-name&gt;
  &lt;url-pattern&gt;/DisplayHeader&lt;/url-pattern&gt;
  &lt;/filter-mapping&gt;
  </code></pre>
  
  <p>which i should reverse in order...</p>
  
  <p>The problem is: when i open the web.xml of my project (from the project explorer, see figure below) file i just see this:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://xmlns.jcp.org/xml/ns/javaee" xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd" id="WebApp_ID" version="3.1"&gt;
    &lt;display-name&gt;SetFilterOrder&lt;/display-name&gt;
    &lt;welcome-file-list&gt;
      &lt;welcome-file&gt;index.html&lt;/welcome-file&gt;
      &lt;welcome-file&gt;index.htm&lt;/welcome-file&gt;
      &lt;welcome-file&gt;index.jsp&lt;/welcome-file&gt;
      &lt;welcome-file&gt;default.html&lt;/welcome-file&gt;
      &lt;welcome-file&gt;default.htm&lt;/welcome-file&gt;
      &lt;welcome-file&gt;default.jsp&lt;/welcome-file&gt;
    &lt;/welcome-file-list&gt;
  &lt;/web-app&gt;
  </code></pre>
  
  <p><a href="https://i.stack.imgur.com/LJv2M.png" rel="nofollow noreferrer">web.xml location in the explorer</a></p>
  
  <p>am i just missing the right web.xml file path or this web.xml is the result of using the "Generate web.xml delpoyment descriptor" option?</p>