title: Simple web application filter doesn't filter request
body: <p>Starting my way with STS and created a new basic "Hello World" Spring MVC project.
  I wanted to add a filter to my app so I created a filter (HelloWorldFilter.java) with the following doFilter method:</p>
  
  <pre><code>public void doFilter(ServletRequest request, ServletResponse response,
              FilterChain chain) throws IOException, ServletException {
          System.out.println("Entering Filter");
          request.setAttribute("hello", "Hello World from HelloWorldFilter!");
          chain.doFilter(request, response);
          System.out.println("Exiting HelloWorldFilter");
      }
  </code></pre>
  
  <p>According to what I read it (my filter) should also be defined in the application context as a spring bean (Spring delegates it to my filter - from <a href="http://static.springsource.org/spring-security/site/docs/3.0.x/reference/security-filter-chain.html" rel="nofollow">this manual</a> )</p>
  
  <p>So in my application context I have:</p>
  
  <pre><code>&lt;bean id="helloWorldFilter" class="com.yl.mvc.filters.HelloWorldFilter"&gt; &lt;/bean&gt;
  </code></pre>
  
  <p>My web.xml contains the following:</p>
  
  <pre><code>&lt;filter&gt;
      &lt;display-name&gt;HelloWorldFilter&lt;/display-name&gt;
      &lt;filter-name&gt;HelloWorldFilter&lt;/filter-name&gt;
      &lt;filter-class&gt;org.springframework.web.filter.DelegatingFilterProxy&lt;/filter-class&gt;
  &lt;/filter&gt;
  &lt;filter-mapping&gt;
      &lt;filter-name&gt;HelloWorldFilter&lt;/filter-name&gt;
      &lt;url-pattern&gt;/*&lt;/url-pattern&gt;
  &lt;/filter-mapping&gt;
  </code></pre>
  
  <p>In my .jsp file I added:</p>
  
  <pre><code>&lt;P&gt;&lt;%=request.getAttribute("hello")%&gt;&lt;/P&gt;
  </code></pre>
  
  <p>But all I see in my web-page is null (I expected Hello World from HelloWorldFilter!).
  The filter doesn't even get invoked..</p>
  
  <p>Am I missing something here?</p>
  
  <p>Thanks in advance,
  Yogi</p>