tags:

views:

168

answers:

2

I would like to prevent Tomcat from listing the files in a directory when the URL ends at directory. This would be like .htaccess for apache.

So that when a user navigates to : www.test.com/f_apps/ -- nothing is lised or error message but going to: www.test.com/f_apps/welcome.jsp -- works correctly

I assume it's a change to META-INF/context.xml but I'm still new to Tomcat stuff so wasn't sure how to modify it for this change.

+1  A: 

You need to disable the DefaultServlet's listings setting in /conf/web.xml.

<init-param>
    <param-name>listings</param-name>
    <param-value>false</param-value>
</init-param>

You can find details in its documentation: http://tomcat.apache.org/tomcat-6.0-doc/default-servlet.html

BalusC
A: 

See http://linux-sxs.org/internet_serving/c581.html, you can update the web.xml to do this:

This is the first section in web.xml. The options that concern us are :

<init-param>
    <param-name>listings</param-name>
    <param-value>true</param-value>
 </init-param>

 Change <param-value> to false and you turn off directory listing. It is that simple.
Kaleb Brasee