0

Am very New to jetty. I have a sample code that am practicing with. But i dont seem to understand which of the jetty classes in my code is used to create the client connection to the jetty server. For example in core java socket programming, the client can establish a connection with the server through the following code

               Socket socket = serverSocket.accept();

where serverSocket is an instance of java ServerSocket class. My code works fine anyway But I want to know which of the classes in jetty is playing the part of Socket class in the one line code above.

Here is a sample of my code:

     ServletContextHandler context = new ServletContextHandler(ServletContextHandler.SESSIONS);
    context.setContextPath("/");

    Server jettyServer = new Server(5500);
    jettyServer.setHandler(context);

    ServletHolder jerseyServlet = context.addServlet(org.glassfish.jersey.servlet.ServletContainer.class, "/*");
    jerseyServlet.setInitOrder(0);

    // Tells the Jersey Servlet which REST service/class to load.
    jerseyServlet.setInitParameter("jersey.config.server.provider.classnames",
            ModelInn.class.getCanonicalName() );

    try {
        jettyServer.start();
        jettyServer.join();

    } catch (Exception ex) {
        Logger.getLogger(HandleClient.class.getName()).log(Level.SEVERE, null, ex);
    } finally {
        jettyServer.destroy();
    }
Young Emil
  • 1,892
  • 1
  • 19
  • 30
  • hmmm if your code works fine, what's the problem ? – niceman Jun 30 '16 at 12:42
  • Am new to jetty as I have said earlier. I came across this sample and it works fine in my project. But I dont understand which jetty class plays the role of the Socket class I talked about. – Young Emil Jun 30 '16 at 13:38

1 Answers1

0

A Jetty server is an web server, so any client side Java code that could send a request to a generic web server should work with a Jetty server. How to do that is a question has been asked and answered many times. For example:

Community
  • 1
  • 1
Stephen C
  • 632,615
  • 86
  • 730
  • 1,096