How can I use static web content like js and css in my embedded web application?
If I have web content in src/main/webapp.
I've tried with:
ServletContextHandler contextHandler = new ServletContextHandler(ServletContextHandler.SESSIONS);
contextHandler.setContextPath("/mypath");
ResourceHandler resourceHandler = new ResourceHandler();
resourceHandler.setBaseResource(Resource.newClassPathResource("/src/main/webapp/");
// I've also tried with resourceHandler.setResourceBase("/src/main/webapp/");
ContextHandlerCollection contexts = new ContextHandlerCollections();
contexts.setHandlers(new Handler[] { contextHandler, resourceHandler });
Server jettyServer = new Server(8080);
jettyServer.setHAndler(contexts);
try
{
jettyServer.start();
jettyServer.join();
}
catch (Exception e)
{
}