Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[jetty-users] wiring up a simple Servlet using embedding jetty

My pom.xml:

 <dependency>
            <groupId>org.eclipse.jetty</groupId>
            <artifactId>jetty-server</artifactId>
            <version>7.6.2.v20120308</version>
        </dependency>

        <!-- Servlet -->
        <dependency>
            <groupId>javax.servlet</groupId>
            <artifactId>servlet-api</artifactId>
            <version>2.5</version>
            <scope>provided</scope>
        </dependency>




main method:

import org.eclipse.jetty.server.Handler;
import org.eclipse.jetty.server.Server;
import org.eclipse.jetty.server.handler.ContextHandlerCollection;
import org.eclipse.jetty.server.handler.HandlerCollection;

public static void main(String[] args) throws Exception {

        Server server = new Server(8080);

        HandlerCollection handlers = new HandlerCollection();
        ContextHandlerCollection contextHandlerCollection = new ContextHandlerCollection();
        Context servletContext = new Context(contextHandlerCollection, "/");

        servletContext.addServlet(new ServletHandler(new TestServlet()), "/test");

        handlers.setHandlers(new Handler[]{ contextHandlerCollection});
        server.setHandler(handlers);

        server.start();
        server.join();

    }


Now the 'Context' class isn't currently resolving, which namespace should it be from?
Or is the Context class not in jetty 7?

(I'm reading now to do this and it seems it is for an older version of jetty).

Back to the top