How to execute Multiple filters

ponse response)  
    throws IOException, ServletException  
    {  
        response.setContentType("text/html");  
      
        PrintWriter out = response.getWriter();  
         
        out.println("<br>I am servlet");  
    }  

import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;

public class MyServlet extends HttpServlet {

    public void doPost(HttpServletRequest request, HttpServletResponse response)
    throws IOException, ServletException
    {
        response.setContentType("text/html");
 
        PrintWriter out = response.getWriter();
      
        out.println("<br>I am servlet");
    }
}
 


Please help how to do this. Specially the web.xml file mapping.

Your form action will have nothing at all to do with the filters; it should be the URL of the servlet.

When properly configured, the filters will automatically be executed when the servlet is invoked. You do not need to address the filters in the action URL. The way to make it work is to set up the servlet and the filter properly in the web.xml. How have you done that?

<web-app>  
<filter>  
   <filter-name>info</filter-name>  
   <filter-class>f1</filter-class>  
</filter>  
 
<filter-mapping>  
   <filter-name>info</filter-name>  
    <url-pattern>/info</url-pattern>  
</filter-mapping>  
 
<filter>  
   <filter-name>info2</filter-name>  
   <filter-class>f2</filter-class>  
</filter>  
 
<filter-mapping>  
   <filter-name>info2</filter-name>  
    <url-pattern>/info</url-pattern>  
</filter-mapping>  
 
<filter>  
   <filter-name>info3</filter-name>  
   <filter-class>f3</filter-class>  
</filter>  
 
<filter-mapping>  
   <filter-name>info3</filter-name>&n

Back  [1] [2] [3] [4] [5] [6] Next

Copyright © 2007-2012 www.chuibin.com Chuibin Copyright