I created Filterto check Cookiewith the request object and the forwardrequest, respectively, thanks to this and this . Now I want to display this Filteronly for welcome-filehow I declared it in web.xml.Let's say I have welcome-fileit index.html, then I need to display Filterfor www.example.com/and www.example.com/index.html, but not for anything else, such as www.example.com/foo/*or www.example.com/*not allowed, I mean NOT anything other than the request welcome-file. I am using the Apache Tomcat 7.0.22 container.
Filter
Cookie
forward
welcome-file
web.xml
index.html
www.example.com/
www.example.com/index.html
www.example.com/foo/*
www.example.com/*
Just add them to your web.xml
<filter> <filter-name>myFilter</filter-name> <filter-class>com.examples.myFilter</filter-class> </filter> <filter-mapping> <filter-name>myFilter</filter-name> <url-pattern>/index.html</url-pattern> </filter-mapping>