title: Servlet Filter - Error 404--Not Found From RFC 2068 Hypertext Transfer Protocol -- HTTP/1.1
body: <p>iam using the below code in servlet filters to avoid direct acess of pages from the URL but i get <strong>Error 404--Not Found - From RFC 2068 Hypertext Transfer Protocol -- HTTP/1.1</strong> irrespective of the URL i try.</p>
  
  <p>Code:</p>
  
  <pre><code>  public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException {
  
      HttpServletRequest req = (HttpServletRequest) request;
      HttpServletResponse res = (HttpServletResponse) response;
  
      String uri = req.getRequestURI();
      this.context.log("Requested Resource::"+uri);
  
      HttpSession session = req.getSession(false);
      if(session == null &amp;&amp; !(uri.endsWith("html") || uri.endsWith("LoginServlet"))){
          this.context.log("Unauthorized access request");
          res.sendRedirect("login.html");
      }else{
          // pass the request along the filter chain
          chain.doFilter(request, response);
      }   
  
  }
  </code></pre>
  
  <p>My Web.xml </p>
  
  <pre><code>    &lt;?xml version="1.0" encoding="UTF-8"?&gt;
   &lt;!DOCTYPE web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN" "http://java.sun.com/dtd/web-app_2_3.dtd"&gt;
   &lt;web-app&gt;
   &lt;display-name&gt;ServletFilterExample&lt;/display-name&gt;
   &lt;filter&gt;
  &lt;filter-name&gt;RequestLoggingFilter&lt;/filter-name&gt;
  &lt;filter-class&gt;com.journaldev.servlet.filters.RequestLoggingFilter&lt;/filter-class&gt;
  &lt;/filter&gt;
  &lt;filter&gt;
  &lt;filter-name&gt;AuthenticationFilter&lt;/filter-name&gt;
  &lt;filter-class&gt;com.journaldev.servlet.filters.AuthenticationFilter&lt;/filter-class&gt;
  &lt;/filter&gt;
  
  &lt;filter-mapping&gt;
  &lt;filter-name&gt;RequestLoggingFilter&lt;/filter-name&gt;
  &lt;url-pattern&gt;/*&lt;/url-pattern&gt;
  &lt;/filter-mapping&gt;
  &lt;filter-mapping&gt;
  &lt;filter-name&gt;AuthenticationFilter&lt;/filter-name&gt;
  &lt;url-pattern&gt;/*&lt;/url-pattern&gt;
  &lt;/filter-mapping&gt;
  &lt;welcome-file-list&gt;
  &lt;welcome-file&gt;login.html&lt;/welcome-file&gt;
  &lt;/welcome-file-list&gt;
   &lt;/web-app&gt;
  </code></pre>
  
  <p>Environment used: Weblogic server 11gR1 and web app 2.5</p>
  
  <p>I'm Hitting the url : </p>
  
  <pre><code>http://localhost:7001/Filters/LoginServlet
  </code></pre>
  
  <p>Could you please help.</p>
  
  <p>Thanks.</p>