private void addResourceHandler(String contextPath, String filePath) throws Exception { if (handlerCollection != null) { logger.log(Level.INFO, "Adding resource : " + contextPath + "=>" + filePath); ResourceHandler resourceHandler = new ResourceHandler(); resourceHandler.setResourceBase(filePath); logger.log(Level.INFO, "serving: " + resourceHandler.getBaseResource()); ContextHandler contextHandler = new ContextHandler(contextPath); contextHandler.setHandler(resourceHandler); handlerCollection.addHandler(contextHandler); try { resourceHandler.start(); contextHandler.start(); } catch (Exception e) { logger.log(Level.INFO, "Could not start resource context", e); } } }