title: web.xml - Java Servlet Filters - Not being run before processing the JSP page (on Tomcat)
body: <p>I am fairly new to Servlet Filters and have basically joined a project using them and added an additional filter to the <code>web.xml</code> file (deployed on <em>Tomcat 5.5</em>). </p>
  
  <p>I am 95% sure that at some point it was working correctly but now when debugging if I put breakpoints at the top of the JSP page I am trying to view (<code>login.jsp</code>), it's template page (<code>page.jsp</code>) and within both of the configured filter's <code>doFilter()</code> method; it runs through the whole of the <code>login.jsp</code> page (top to bottom), then <code>page.jsp</code> and the starts processing the filters.</p>
  
  <p>I need it to run the filters first, since one of them determines the language the page should be displayed in (checking cookies, db settings and browser settings) which should then apply to the <code>login.jsp</code>.</p>
  
  <p>Has anyone got any suggestions as to what might be going wrong? </p>
  
  <p>There is a lot of code I could be posting but am not convinced that would be of any use since it's all working just in the wrong order.</p>
  
  <p>Snippets from the web.xml:</p>
  
  <pre><code>&lt;web-app&gt;
  ...
  &lt;filter&gt;
          &lt;filter-name&gt;SetSecurityContextFilter&lt;/filter-name&gt;
          &lt;filter-class&gt;
              com.section2.SecurityContextServletFilter
          &lt;/filter-class&gt;
      &lt;/filter&gt;
  
  &lt;filter&gt;
      &lt;filter-name&gt;SetLocaleFilter&lt;/filter-name&gt;
      &lt;filter-class&gt;
          com.section2.locale.LocaleServletFilter
      &lt;/filter-class&gt;
  &lt;/filter&gt;
  
  &lt;filter&gt;
      &lt;filter-name&gt;trinidad&lt;/filter-name&gt;
      &lt;filter-class&gt;org.apache.myfaces.trinidad.webapp.TrinidadFilter&lt;/filter-class&gt;
  &lt;/filter&gt;
  
  &lt;filter&gt;
      &lt;filter-name&gt;ActiveUserFilter&lt;/filter-name&gt;
      &lt;filter-class&gt;com.section2.ActiveUserFilter&lt;/filter-class&gt;
  &lt;/filter&gt;
  
      &lt;filter-mapping&gt;
          &lt;filter-name&gt;trinidad&lt;/filter-name&gt;
          &lt;servlet-name&gt;Faces Servlet&lt;/servlet-name&gt;
      &lt;/filter-mapping&gt;
  
      &lt;filter-mapping&gt;
          &lt;filter-name&gt;SetSecurityContextFilter&lt;/filter-name&gt;
          &lt;url-pattern&gt;/*&lt;/url-pattern&gt;
      &lt;/filter-mapping&gt;
  
      &lt;filter-mapping&gt;
          &lt;filter-name&gt;SetLocaleFilter&lt;/filter-name&gt;
          &lt;url-pattern&gt;/*&lt;/url-pattern&gt;
      &lt;/filter-mapping&gt;
  
      &lt;filter-mapping&gt;
          &lt;filter-name&gt;ActiveUserFilter&lt;/filter-name&gt;
          &lt;url-pattern&gt;/pages/section2/user/*&lt;/url-pattern&gt;
      &lt;/filter-mapping&gt;
  
  ...
  &lt;/web-app&gt;
  </code></pre>
  
  <p>Thanks in advance.</p>