There seem to be many questions arround it here but none helped me.... Tried to have single Java Class as startingpoint running embedded Jetty with Jersey to provide either Webpages and JSON interfaces...However even first step failed to provide multiple pages.
this works fine
ServletHolder jerseyServlet = context.addServlet(org.glassfish.jersey.servlet.ServletContainer.class, "/*");
jerseyServlet.setInitOrder(0);
jerseyServlet.setInitParameter("jersey.config.server.provider.classnames", EntryPoint.class.getCanonicalName());
but adding another content failed. How can I provide multiple pages providing different content types ? Is the only solution to added the content in that single EntryPoint class ?
Thanks in advance for any hint what is needed to change that
public class App {
public static void main(String[] args) throws Exception {
ServletContextHandler context = new ServletContextHandler(ServletContextHandler.SESSIONS);
context.setContextPath("/");
Server jettyServer = new Server(8080);
jettyServer.setHandler(context);
ServletHolder jerseyServlet = context.addServlet(org.glassfish.jersey.servlet.ServletContainer.class, "/*");
jerseyServlet.setInitOrder(0);
jerseyServlet.setInitParameter("jersey.config.server.provider.classnames", EntryPoint.class.getCanonicalName());
ServletHolder helloWorldServlet = context.addServlet(org.glassfish.jersey.servlet.ServletContainer.class, "/*");
helloWorldServlet.setInitOrder(1);
helloWorldServlet.setInitParameter("jersey.config.server.provider.classnames", HelloWorldService.class.getCanonicalName());
try {
jettyServer.start();
jettyServer.join();
} catch (Exception e){
System.out.println("Failed running jettyServer with " + e.getMessage());
} finally {
jettyServer.destroy();
}
}
}