title: What is difference between ServletContextHandler.setResourceBase and ResourceHandler.setResourceBase when using Jetty embedded container?
body: <p>I'm using embedded Jetty to create a static web site. Does ServletContextHandler.setResourceBase(&quot;...&quot;) have a same effect as ResourceHandler.setResourceBase(&quot;...&quot;)?</p>
  <p>Example:</p>
  <pre><code>// ServletContextHandler case
  ServletContextHandler context = new ServletContextHandler(ServletContextHandler.SESSIONS);
  context.setResourceBase(&quot;/tmp/...&quot;);
  // ResourceHandler case
  ResourceHandler resourceHandler = new ResourceHandler();
  resourceHandler.setResourceBase(&quot;/tmp/...&quot;);
  </code></pre>
  <p>I have tried test both of them. ResourceHandler works exactly what I want. But otherwise doesn't. What's the difference between them?</p>
  <p>(Sorry for my poor English :P)</p>
  <h3>Update</h3>
  <p>After changed, below is whole code. Context(&quot;/&quot;) serves static files, wsContext(&quot;/ws&quot;) serves web socket endpoints. Of course Context(&quot;/&quot;) is able to serve web socket endpoints as well.</p>
  <pre><code> server = new Server();
   server.setStopAtShutdown(true);
   ServerConnector connector = new ServerConnector(server);
   connector.setPort(8000);
   server.addConnector(connector);
  
   // Setup the basic application &quot;context&quot; for this application at &quot;/&quot;
   // This is also known as the handler tree (in jetty speak)
   ServletContextHandler context = new ServletContextHandler(ServletContextHandler.SESSIONS);
  
   context.setContextPath(&quot;/&quot;);
   context.setResourceBase(System.getProperty(&quot;webapp.path&quot;));
  
   ServletContextHandler wsContext = new ServletContextHandler();
   wsContext.setContextPath(&quot;/ws&quot;);
  
   ContextHandlerCollection contexts=new ContextHandlerCollection();
   contexts.setHandlers(new Handler[]{context, wsContext});
  
   server.setHandler(contexts);
  
   context.addServlet(DefaultServlet.class, &quot;/&quot;);
  
   // Initialize javax.websocket layer
   ServerContainer wsContainer = WebSocketServerContainerInitializer.configureContext(wsContext);
  
   // Add WebSocket endpoint to javax.websocket layer
   // code omitted...
  
   server.start();
   logger.info(&quot;WebServer started.&quot;);
  </code></pre>