Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Programmatically registering a servlet in Jetty 7

Tags:

java

jetty

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

like image 364
phil swenson Avatar asked Dec 29 '09 17:12

phil swenson


1 Answers

The URL to access your servlet is http://localhost:8080/context/hessian-service

like image 126
adrian.tarau Avatar answered Oct 16 '22 13:10

adrian.tarau