package org.getahead.dwrdemo.cli;

import org.directwebremoting.servlet.DwrServlet;
import org.mortbay.jetty.Server;
import org.mortbay.jetty.handler.ResourceHandler;
import org.mortbay.jetty.nio.SelectChannelConnector;
import org.mortbay.jetty.servlet.Context;
import org.mortbay.jetty.servlet.ServletHolder;

/**
 * JettyLauncher.
 */
public class JettyLauncher
{
    /**
     * Sets up and runs server.
     * @param args
     */
    public static void main(String[] args)
    {
        Server server = new Server();

        SelectChannelConnector connector = new SelectChannelConnector();
        connector.setPort(8080);
        server.addConnector(connector);

        Context htmlContext = new Context(server, "/", Context.SESSIONS);
        ResourceHandler htmlHandler = new ResourceHandler();
        htmlHandler.setResourceBase("web");
        htmlContext.setHandler(htmlHandler);

        Context servletContext = new Context(server, "/", Context.SESSIONS);
        ServletHolder holder = new ServletHolder(new DwrServlet());
        holder.setInitParameter("activeReverseAjaxEnabled", "true");
        holder.setInitParameter("debug", "true");
        servletContext.addServlet(holder, "/dwr/*");
        servletContext.setResourceBase("web");

        try
        {
            JettyShutdown.addShutdownHook(server);
            server.start();
            server.join();
        }
        catch (Exception ex)
        {
            ex.printStackTrace();
        }
    }
}

@@ -43,270 +43,128 @@
 org.
-directwebremoting.servlet.DwrServlet;%0Aimport org.mortbay.jetty.Server;%0Aimport org.mortbay.jetty.handler.ResourceHandler;%0Aimport org.mortbay.jetty.nio.SelectChannelConnector;%0Aimport org.mortbay.jetty.servlet.Context;%0Aimport org.mortbay.jetty.servlet.ServletHolder
+mortbay.jetty.Server;%0Aimport org.mortbay.jetty.nio.SelectChannelConnector;%0Aimport org.mortbay.jetty.webapp.WebAppContext
 ;%0A%0A/
@@ -514,33 +514,32 @@
 connector);%0A
-%0A
         
 Context html
@@ -530,810 +530,167 @@
     
-Context htmlContext = new Context(server, %22/%22, Context.SESSIONS);%0A        ResourceHandler htmlHandler = new ResourceHandler();%0A        htmlHandler.setResourceBase(%22web%22);%0A        htmlContext.setHandler(htmlHandler);%0A%0A        Context servletContext = new Context(server, %22/%22, Context.SESSIONS);%0A        ServletHolder holder = new ServletHolder(new DwrServlet());%0A        holder.setInitParameter(%22activeReverseAjaxEnabled%22, %22true%22);%0A        holder.setInitParameter(%22debug%22, %22true%22);%0A        servletContext.addServlet(holder, %22/dwr/*%22);%0A        servletContext.setResourceBase(%22web%22);%0A%0A        try%0A        %7B%0A            JettyShutdown.addShutdownHook(server);%0A            server.start();%0A            server.join();%0A        %7D%0A        catch (Exception ex)%0A        %7B%0A            ex.printStackTrace();%0A        %7D
+server.setStopAtShutdown(true);%0A%0A        server.addHandler(new WebAppContext(%22web%22,%22/dwr%22));%0A%0A        server.addHandler(new WebAppContext(%22test%22,%22/dwr-test%22));
 %0A   

Use more compact Jetty Launcher