At some point, you may need to filter all your projects globally.
Because your project can be designed to rely on and invoke each other.
Modify the Web. xml file under Tomcat under Conf. As in the original web-inif, add filter.
Then package your filter into a jar and place it under the Lib directory under Tomcat, if you know the role of Tomcat's Lib directory.
- <filter>
- <filter-name>appfilter</filter-name>
- <filter-class>com.common.appfilter</filter-class>
- </Filter>
- <filter-mapping>
- <filter-name>appfilter</filter-name>
- <url-pattern>/*</url-pattern>
- <dispatcher>request</Dispatcher>
- <dispatcher>forward</Dispatcher>
- <dispatcher>include</Dispatcher>
- </filter-mapping>
- public class Pathfilter implements Filter {
- public void Destroy () {}
- public void DoFilter (ServletRequest request, servletresponse response,
- Filterchain chain) throws IOException, Servletexception {
- HttpServletRequest req = (httpservletrequest) request;
- HttpServletResponse resp = (httpservletresponse) response;
- String uri = Req.getrequesturi ();
- if (Uri.endswith ("home.htm")) {
- Resp.sendredirect ("/hdsst/home/index.jsp");
- }
- Chain.dofilter (REQ,RESP);
- }
- public void init (Filterconfig filterconfig) throws Servletexception {}
- }
Custom Filter Pack