Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [jetty-users] How can I prevent Directory Listing in WebAppContext

Hi Michael,

I finally resolved this issue; the problem is that for some reason Jetty does not merge the webdefault.xml
with user web.xml properly  when embedded mode is used; I got around this by using the following logic: I hope
it helps someone with similar issue.

   HashMap hmap = new HashMap<String, String>();
   hmap.put("dirAllowed", "false");
   hmap.put("redirectWelcome", "false");
   hmap.put("aliases", "false");
   ServletHolder []svh = wc.getServletHandler().getServlets();
   if(svh != null && svh.length > 0)
   {
           for(int j = 0; j < svh.length; j++)
      {
              ServletHolder svh1 = svh[j];
            if(svh1.getClassName() != null && svh1.getClassName().endsWith(DEFAULT_SERVLET))
            {
               svh1.setInitParameters(hmap);
             }
       }
   }

Thanks,

Ike




From:        Michael Gorovoy <michael@xxxxxxxxxxx>
To:        Ike Ikonne/Dallas/IBM@IBMUS
Cc:        JETTY user mailing list <jetty-users@xxxxxxxxxxx>, jetty-users-bounces@xxxxxxxxxxx
Date:        04/15/2011 11:09 AM
Subject:        Re: [jetty-users] How can I prevent Directory Listing in WebAppContext
Sent by:        mgorovoy@xxxxxxxxxxx




I believe it is done for you automatically, you just need to set initParameter on WebAppContext as specified in DefaultServlet's JavaDoc.

-Michael

On Fri, Apr 15, 2011 at 12:04 PM, Ike Ikonne <iikonne@xxxxxxxxxx> wrote:
Hi Michael,

Thanks, so, I need to add this servlet as part of handlers to my webapp or is it automatically

added when I create an instance of  webAppContext?


Thanks,


Ike




From:        
Michael Gorovoy <michael@xxxxxxxxxxx>
To:        
JETTY user mailing list <jetty-users@xxxxxxxxxxx>
Cc:        
Ike Ikonne/Dallas/IBM@IBMUS, jetty-users-bounces@xxxxxxxxxxx
Date:        
04/15/2011 10:51 AM
Subject:        
Re: [jetty-users] How can I prevent Directory Listing in WebAppContext
Sent by:        
mgorovoy@xxxxxxxxxxx





This feature is controlled by dirAllowed parameter of org.eclipse.jetty.servlet.DefaultServlet.

-Michael

On Fri, Apr 15, 2011 at 11:44 AM, Ike Ikonne <
iikonne@xxxxxxxxxx> wrote:
Hi all,


I am running Jetty in embedded mode and I have a WebAppContext; I would like to block users

of this app from browsing directories in this app, is there a way that I can programmatically do that?

I have looked through the WebAppContext but there doesn't seem to be anyway to do it from that.


Thanks,


Ike



_______________________________________________
jetty-users mailing list

jetty-users@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/jetty-users




Back to the top