Alex Rivera | Logout

Migration from Jetty 6 to Jetty 8

Asked 2012-02-14T14:47:53.737
8

I use jetty6 in simple application as embedded servlet container. I decided to update it to Jetty 8. In jetty 6 it was pretty simple to start the server:

Server server = new Server(8080);
Context context = new Context(server, "/", Context.SESSIONS);
context.addServlet(MyServlet.class, "/communication-service");
server.start();

but it doesn't work in Jetty8. Unfortunately I can't find any simple example for this version. Can't instantiate Context with error

an enclosing instance that contains
    org.eclipse.jetty.server.handler.ContextHandler.Context is required

because now it is an inner class and also no such constructor.

Most examples are for jetty 6 and 7. Could you please provide simple example how to start servlet at jetty 8?

Edit
Report

1 Answer

1

Jetty is nowadays part of Eclipse. The documentation here is for Jetty 7 but claims it should work for Jetty 8. There's an example of using servlets towards the end of the page.

answered 2012-02-14T15:28:39.507

Your Answer