title: Getting a 403 on root requests when using a ResourceHandler and custom handler in Jetty
body: <p>In (embedded) Jetty, I'm trying to use a ResourceHandler to serve static files and a custom handler to respond to dynamic requests. Based on <a href="http://wiki.eclipse.org/Jetty/Tutorial/Embedding_Jetty#Configuring_a_File_Server" rel="nofollow">this page</a> I have a setup that looks like this:</p>
  
  <pre><code>public static void main(String[] args) throws Exception
  {
      Server server = new Server();
      SelectChannelConnector connector = new SelectChannelConnector();
      connector.setPort(8080);
      server.addConnector(connector);
  
      ResourceHandler resource_handler = new ResourceHandler();
      resource_handler.setDirectoriesListed(false);
  
      resource_handler.setResourceBase(".");
  
      HandlerList handlers = new HandlerList();
      handlers.setHandlers(new Handler[] { resource_handler, new MyHandler() });
      server.setHandler(handlers);
  
      server.start();
      server.join();
  }
  </code></pre>
  
  <p>This works in the sense that it correctly:</p>
  
  <ul>
  <li>Serves up static content from files in my public directory, like /public/style.css</li>
  <li>Runs MyHandler on paths that aren't present in the public directory, like /foo/bar</li>
  </ul>
  
  <p>The problem is that I get a 403 in response to the root path (/). MyHandler is capable of responding to those requests, but they get intercepted by the ResourceHandler first. Is there any way to force Jetty to send / requests to MyHandler?</p>
  
  <p>Thanks in advance!</p>