Package com.hascode.tutorial.container

Source Code of com.hascode.tutorial.container.JettyEmbeddedRunner

package com.hascode.tutorial.container;

import org.eclipse.jetty.server.Server;
import org.eclipse.jetty.server.ServerConnector;
import org.eclipse.jetty.servlet.ServletContextHandler;
import org.eclipse.jetty.servlet.ServletHolder;

import com.hascode.tutorial.servlet.DatePrintServlet;

public class JettyEmbeddedRunner {
  public void startServer() {
    try {
      Server server = new Server();
      ServerConnector c = new ServerConnector(server);
      c.setIdleTimeout(1000);
      c.setAcceptQueueSize(10);
      c.setPort(8080);
      c.setHost("localhost");
      ServletContextHandler handler = new ServletContextHandler(server,
          "/app", true, false);
      ServletHolder servletHolder = new ServletHolder(
          DatePrintServlet.class);
      handler.addServlet(servletHolder, "/date");
      server.addConnector(c);
      server.start();
    } catch (Exception e) {
      e.printStackTrace();
    }
  }
}
TOP

Related Classes of com.hascode.tutorial.container.JettyEmbeddedRunner

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.