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();
}
}