users@glassfish.java.net

Re: deny directory access

From: Wolfram Rittmeyer <w.rittmeyer_at_jsptutorial.org>
Date: Wed, 25 Mar 2009 22:27:34 +0100

Ken--_at_newsgroupstats.hk wrote:
> Hi All,
>
> How to deny directory access in gf3 like apache does?
>
> <VirtualHost>
> <Location "/include/">
> AllowOverride None
> deny from all
> </Location>
> </VirtualHost>
>
> Thanks and Best Regards,
> Ken
>
>

If you want to block directory listings in general, this is configured
in the default-web.xml of your domain. It can be found in the directory
  $GF_INSTALL/domains/domain1/config. The file configures among other
things the DefaultServlet which handles web requests for any url that is
not mapped to other servlets. It takes an init param "listings". The
value should be set to "false" if you do not want directory listings.

If you want to drop any request starting with e.g. "/include" there is
no configuration option in GlassFish AFAIK. But you could use a filter
in which you always respond with a 404 status code. This filter could
then be configured to apply to mappings that fit the directories you do
want to block. Of course this way you would have to write some code
_and_ configure the filter-mappings to be used on the desired folders
(e.g. /include/*). Would this suit your needs?


--
Wolfram Rittmeyer