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 <[email protected]>
To:     Ike Ikonne/Dallas/IBM@IBMUS
Cc:     JETTY user mailing list <[email protected]>, 
[email protected]
Date:   04/15/2011 11:09 AM
Subject:        Re: [jetty-users] How can I prevent Directory Listing in 
WebAppContext
Sent by:        [email protected]



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 <[email protected]> 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 <[email protected]> 
To:        JETTY user mailing list <[email protected]> 
Cc:        Ike Ikonne/Dallas/IBM@IBMUS, [email protected] 
Date:        04/15/2011 10:51 AM 
Subject:        Re: [jetty-users] How can I prevent Directory Listing in 
WebAppContext 
Sent by:        [email protected] 




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 <[email protected]> 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
[email protected]
https://dev.eclipse.org/mailman/listinfo/jetty-users



_______________________________________________
jetty-users mailing list
[email protected]
https://dev.eclipse.org/mailman/listinfo/jetty-users

Reply via email to