1
votes

I have created a filter class which is in a jar in WEB-INF/lib of my application. Now I need to map in web.xml of Tomcat/conf to that class file.

I thought tomcat exposes all class files in WEB-INF/lib so that classes are available directly.

Apache's deployment guide quotes

When you install an application into Tomcat (or any other 2.2 or later Servlet container), the classes in the WEB-INF/classes/ directory, as well as all classes in JAR files found in the WEB-INF/lib/ directory, are made visible to other classes within your particular web application. Thus, if you include all of the required library classes in one of these places (be sure to check licenses for redistribution rights for any third party libraries you utilize), you will simplify the installation of your web application -- no adjustment to the system class path (or installation of global library files in your server) will be necessary.

I have given path in filter as com.(company_name).(package_name).class_name

but tomcat is not picking it up. Am I doing something wrong here?

1
My mistake. Ill rectify it.Pramod
Can you kindly explain what do mean by go in Server? I specifically need it to map to WAR. is that possible>Pramod
You see, it is a filter class which needs to add response headers to each page of application. Thats in WAR.Pramod
I did that. but /WEB-INF/web.xml wasn't adding response headers to all pages(specifically static html pages which were coming through href) so resolved to tomcats web.xmlPramod

1 Answers

0
votes

As @BalusC mentioned in comments it is not possible to map to your application's WEB-INF/lib from tomcat's web.xml (tomcat/conf/web.xml).

Solution would be to put that filter class in a separate jar and place it in tomcat's lib (tomcat/lib). Currently that seems to be the only solution possible.