I'm writing some example code where an embedded Jetty server is started. The server must load exactly one servlet, send all requests to the servlet and listen on localhost:80
My code so far:
static void startJetty() {
try {
Server server = new Server();
Connector con = new SelectChannelConnector();
con.setPort(80);
server.addConnector(con);
Context context = new Context(server, "/", Context.SESSIONS);
ServletHolder holder = new ServletHolder(new MyApp());
context.addServlet(holder, "/*");
server.start();
} catch (Exception ex) {
System.err.println(ex);
}
}
Can i do the same with less code/lines ? (Jetty 6.1.0 used).