Package javaSrv

Source Code of javaSrv.JavaServer

package javaSrv;

import org.eclipse.jetty.server.Server;

import org.eclipse.jetty.servlet.*;

import javaSrv.ServerConf;


public class JavaServer {
  public static void main(String[] args) throws Exception
    {
    int port = 0;
    try{
    port = ServerConf.getPort();
    }catch(Exception e){
      System.err.println("Cannot start server. Reason: Cannot read port from config. Make sure you have server config json in cnf folder. ");
      e.printStackTrace(System.err);
      System.exit(1);
    }
   
    //Context
        ServletContextHandler context = new ServletContextHandler(ServletContextHandler.NO_SESSIONS);
        context.setContextPath("/google");

        //Context -> Servlet
        context.addServlet(new ServletHolder(new JavaServlet()),"/*");
        context.addServlet(new ServletHolder(new OneServlet("This is title generated by ServletOne")),"/one/*");
      
       
       
        //Context -> Server
        Server server = new Server(port);
        server.setHandler(context);
        //server run
        server.start();
        server.join();
    }
 


TOP

Related Classes of javaSrv.JavaServer

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.