Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[jetty-users] HTTP 403

Hi all,

I have an embedded jetty that is used to serve static resources only; how can
I tell Jetty to stop directory listing request from clients?  I have the following piece
of code, but it doesn't seem to be doing the job.  What am I missing?  Here is the
code snippet.  I am running Jetty 7


            context = new ContextHandler();
            context.setContextPath("/");
            context.setResourceBase("../xxx/jetty/docroot");
            rh = new ResourceHandler();
            rh.setDirectoriesListed( false );
            rh.setAliases( false );
            context.setHandler(rh);
            handlers[0] = context;
           
            context = new ContextHandler();
            context.setContextPath("/lib");
            context.setResourceBase(config.getLibRoot());
            rh = new ResourceHandler();
            rh.setDirectoriesListed( false );
            rh.setAliases( false );
            context.setHandler(rh);
            handlers[1] = context;
           
            hc.setHandlers(handlers);
            server.setHandler(hc);

When I try, say, http://localhost:8080/lib/res I am getting 404 instead
of 403. I was expecting to get 403 instead of 404. Any suggestions would be appreciated.

Thanks,

Ike

Back to the top