You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Roland Lammel <rl...@brabbel.net> on 2007/01/08 14:52:17 UTC

Application specific directory listings not working as expected

Hi all,

The default setting for directory listing is false in tomcat's
web.xml(which is good idea anyway), some applications require
directory listings
though.

Trying to follow a configuration posted earlier, I found that to be not
working as expected.
The idea is the configure a "application specific" default servlet (simply
copy from tomcat's web.xml), change the servlet name and add a servlet
mapping for the specific directory to be allowed for listing.

This is the applications excerpt of the mapping:

<servlet>
   <servlet-name>MyListing</servlet-name>
   <servlet-class>org.apache.catalina.servlets.DefaultServlet</servlet-class>
   <init-param>
     <param-name>listings</param-name>
     <param-value>true</param-value>
   </init-param>
   <load-on-startup>1</load-on-startup>
 </servlet>
 <servlet-mapping>
   <servlet-name>MyListing</servlet-name>
   <url-pattern>/myappdir/</url-pattern>
 </servlet-mapping>

I see that the servlet MyListing is actually used and processing the
request, but directory listing is still forbidden (with 404), as if the
init-param "listings" would simply be ignored.

Any comments on why this config does not work as expected or other possible
approaches would be higly appreciated.

BR
-- 
Roland Lammel

"Enjoy your job, make lots of money, work within the law. Choose any two."

RE: Application specific directory listings not working as expected

Posted by "Caldarale, Charles R" <Ch...@unisys.com>.
> From: roland.lammel@gmail.com 
> Subject: Application specific directory listings not working 
> as expected
> 
> The idea is the configure a "application specific" default 
> servlet (simply copy from tomcat's web.xml), change the
> servlet name and add a servlet mapping for the specific
> directory to be allowed for listing.

I think the problem with the above is that the DefaultServlet does not
include the <url-pattern> when retrieving static resources, including
directory listings.  Consequently, the desired directory is never
actually found, resulting in the 404 status.

>  <servlet-mapping>
>    <servlet-name>MyListing</servlet-name>
>    <url-pattern>/myappdir/</url-pattern>
>  </servlet-mapping>

Try changing the <url-pattern> above to just a single slash; this should
get you the listings you need, although it does open up all of the
directories of your app that don't have welcome files and aren't under
WEB-INF.  If you really want to give listing access to only a select set
of directories, you may have to place them in a separate webapp.

 - Chuck


THIS COMMUNICATION MAY CONTAIN CONFIDENTIAL AND/OR OTHERWISE PROPRIETARY
MATERIAL and is thus for use only by the intended recipient. If you
received this in error, please contact the sender and delete the e-mail
and its attachments from all computers.

---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org