简体   繁体   中英

Programmatically registering a servlet in Jetty 7

I'm trying to register a Servlet in Jetty 7.0 programmatically. All the examples I find are for Jetty 6, and Jetty 7 is quite 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 the sever starts, but the client fails on connect: Caused by: java.io.FileNotFoundException: http://localhost:8080/hessian-service

I see nothing in my browser at http://localhost:8080/hessian-service . Thanks

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM