Return to Snippet

Revision: 48274
at January 22, 2013 12:46 by laurenceosx


Updated Code
// this example is based on http://groovy.codehaus.org/Grape

import org.mortbay.jetty.Server
import org.mortbay.jetty.servlet.*
import groovy.servlet.*

import org.mortbay.jetty.webapp.WebAppContext;

@Grab(group = 'org.mortbay.jetty', module = 'jetty-embedded', version = '6.1.0')
def runServer() {

    def server = new Server(1234)
    
    def context = new Context(server, "/", Context.SESSIONS);
    
    context.resourceBase = "."
    
    context.addServlet(DefaultServlet, "/")
    
    context.addServlet(TemplateServlet, "*.gsp")
    
    
    //
    /*
     WebAppContext webapp = new WebAppContext();
     webapp.setContextPath("/");
     webapp.setWar("http-server-0.9-SNAPSHOT");
     server.setHandler(webapp);
     */
    //
    
    server.start()
    //sleep duration
    println "Press enter or return to stop web server."
    System.in.read();
    server.stop()
}

runServer()

Revision: 48273
at January 4, 2012 08:17 by laurenceosx


Updated Code
// this example is based on http://groovy.codehaus.org/Grape

import org.mortbay.jetty.Server
import org.mortbay.jetty.servlet.*
import groovy.servlet.*

import org.mortbay.jetty.webapp.WebAppContext;

@Grab(group = 'org.mortbay.jetty', module = 'jetty-embedded', version = '6.1.0')
def runServer(duration = 1000) {

    def server = new Server(1234)
    
    def context = new Context(server, "/", Context.SESSIONS);
    
    context.resourceBase = "."
    
    context.addServlet(DefaultServlet, "/")
    
    context.addServlet(TemplateServlet, "*.gsp")
    
    
    //
    /*
     WebAppContext webapp = new WebAppContext();
     webapp.setContextPath("/");
     webapp.setWar("http-server-0.9-SNAPSHOT");
     server.setHandler(webapp);
     */
    //
    
    server.start()
    //sleep duration
    println "Press enter or return top stop web server."
    System.in.read();
    server.stop()
}

runServer()

Revision: 48272
at June 28, 2011 02:25 by laurenceosx


Initial Code
// this example is from http://groovy.codehaus.org/Grape

import org.mortbay.jetty.Server
import org.mortbay.jetty.servlet.*
import groovy.servlet.*

@Grab(group = 'org.mortbay.jetty', module = 'jetty-embedded', version = '6.1.0')
def runServer(duration) {
    def server = new Server(8080)
    def context = new Context(server, "/", Context.SESSIONS);
    context.resourceBase = "."
    context.addServlet(TemplateServlet, "*.gsp")
    server.start()
    sleep duration
    server.stop()
}

runServer(10000)

Initial URL
http://groovy.codehaus.org/Grape

Initial Description
this example is based on http://groovy.codehaus.org/Grape

Initial Title
Groovy Quick and Dirty Jetty web server with gsp support (using TemplateServlet)

Initial Tags
groovy

Initial Language
Groovy