title: Embedded Jetty serving static content with form authentication
body: <p>I try to use the Forms-Based authentication within an embedded Jetty 6.1.7 project.</p>
  
  <p>That's why I need to serve servlets and html (login.html) under the same context
  to make authentication work. I don't want to secure the hole application since
  different context should need different roles. The jetty javadoc states that a 
  ContextHandlerCollection can handle different handlers for one context but I don't
  get it to work. My sample ignoring the authentication stuff will not work, why?</p>
  
  <pre><code>ContextHandlerCollection contexts = new ContextHandlerCollection();
  
  // serve html       
  Context ctxADocs= new Context(contexts,"/ctxA",Context.SESSIONS);
  ctxADocs.setResourceBase("d:\\tmp\\ctxA");
  ServletHolder ctxADocHolder= new ServletHolder();
  ctxADocHolder.setInitParameter("dirAllowed", "false");    
  ctxADocHolder.setServlet(new DefaultServlet());
  ctxADocs.addServlet(ctxADocHolder, "/");   
  
  // serve a sample servlet
  Context ctxA = new Context(contexts,"/ctxA",Context.SESSIONS);  
  
  ctxA.addServlet(new ServletHolder(new SessionDump()), "/sda");
  ctxA.addServlet(new ServletHolder(new DefaultServlet()), "/");
  
  contexts.setHandlers(new Handler[]{ctxA, ctxADocs});
  
  // end of snippet
  </code></pre>
  
  <p>Any helpful thought is welcome!</p>
  
  <p>Thanks.</p>
  
  <p>Okami</p>