CodeGrabber
{ USER }
posts: 23
last: 28-Apr-2008
TITLE: Minimal Jetty http server with Java servlet
DESCRIPTION: This will start a Jetty http server with a single Java servlet at the root
Submitted: 09-Apr-2008 11:39:00 ( 32w 0d 6h ago ) Language: Java (*.java)
Views: 206 Lines of Code: 23 LINES
Rating:
rate: star1
star2
star3
star4
star5
dstar1
dstar2
dstar3
dstar4
dstar5  ( rated! )
  { 0.00 / 5 }
Difficulty: Intermediate
Bookmark
/* Author: CodeGrabber
   Date: 09-04-2008
   Filename: 
   Description: Minimal Jetty http server with Java servlet
   History: 
*/

/* This will start a Jetty http server with a single Java servlet at the root. See http://www.mortbay.org/ for Jetty downloads. This needs HelloWorldServlet from one of my other posts. Make life easier by downloading my ant build.xml as well. */

package com.babblemind;

import org.mortbay.jetty.Server;
import org.mortbay.jetty.servlet.Context;
import org.mortbay.jetty.servlet.ServletHolder;

public class JettyLauncher {
    public static void main(String[] args) throws Exception {
	Server server = new Server(8080);    
	Context root = new Context(server, "/", Context.SESSIONS);
	root.addServlet(new ServletHolder(new HelloWorldServlet()), "/*");
	server.start();
    }
}