Programmatically registering a servlet in Jetty 7

I am trying to register a servlet in Jetty 7.0 programmatically. All the examples I find are for Jetty 6, and Jetty 7 is completely different. Here is my server side:

import org.eclipse.jetty.server.Server; import org.eclipse.jetty.servlet.ServletContextHandler; public class Bootstrapper { public static void main(String[] args) throws Exception{ Server server = new Server(8080); ServletContextHandler servletContextHandler = new ServletContextHandler(server, "/context", true, false); servletContextHandler.addServlet(HessianService.class, "/hessian-service"); server.start(); System.out.println("started"); } } 

The result of this test is to start the server, but the client fails to connect: thrown: java.io.FileNotFoundException: http: // localhost: 8080 / hessian-service

I do not see anything in my browser http: // localhost: 8080 / hessian-service . Thanks

+7
java jetty
source share
1 answer
+6
source share

All Articles