On 23/10/2015 03:39, Pradyut Bhattacharya wrote:
> Hi,
> I  had configured virtual directories in glassfish3.x over which I could 
> write filters.
> For an example I could access files at c:/web from 
> http://localhost/TestApp/web over which I could also place a filter at my web 
> app's web/xml file with
> <filter-mapping>
>     <filter-name>dir_filter</filter-name>
>     <url-pattern>/web/*</url-pattern>
> </filter-mapping>Unfortunately Tomcat 8.0 is not allowing me to write a 
> filter above that. It simply ignores the filters and shows the content in the 
> web directory.
> The problem is anybody can access all of the files in the "web" folder.
> Any how can we place filter over the virtual directories.
> FYI - i have made the web app named "TestApp" and the virtual config is 
> located at "$tomcat_dir/conf/Catalina/localhost" directory with the file name 
> "TestApp#web.xml" file and having the content<?xml version='1.0' 
> encoding='utf-8'?> 
> <Context docBase="C:/web" debug="0" privileged="true"></Context>
> The question is also at stackoverflow - 
> http://stackoverflow.com/questions/33290483/servlet-filter-not-working-over-virtual-directories-in-tomcat
> Tomcat bugzilla - https://bz.apache.org/bugzilla/show_bug.cgi?id=58523

Tomcat is doing exactly what you have configured it to do. There is no
Tomcat bug here, just user error.

With a context.xml file named TestApp#web.xml you have a defined a new
web application with a context path of "/TestApp/web" and a docBase of
"C:\web"

The URL pattern therefore needs to be "/*"

If you want to mount "C:\web" inside an existing web application using
the path "/web" then you need to define a PreResources or PostResources
element using the org.apache.catalina.webresources.DirResourceSet
implementation. See
http://tomcat.apache.org/tomcat-8.0-doc/config/resources.html for more
details.

Mark

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
For additional commands, e-mail: users-h...@tomcat.apache.org

Reply via email to