Groovy 1.7.0

groovy.servlet
Class GroovyServlet

java.lang.Object
  javax.servlet.GenericServlet
      javax.servlet.http.HttpServlet
          groovy.servlet.AbstractHttpServlet
              groovy.servlet.GroovyServlet

class GroovyServlet
extends AbstractHttpServlet

This servlet will run Groovy scripts as Groovlets. Groovlets are scripts with these objects implicit in their scope:

Your script sources can be placed either in your web application's normal web root (allows for subdirectories) or in /WEB-INF/groovy/* (also allows subdirectories).

To make your web application more groovy, you must add the GroovyServlet to your application's web.xml configuration using any mapping you like, so long as it follows the pattern *.* (more on this below). Here is the web.xml entry:

    <servlet>
      <servlet-name>Groovy</servlet-name>
      <servlet-class>groovy.servlet.GroovyServlet</servlet-class>
    </servlet>

    <servlet-mapping>
      <servlet-name>Groovy</servlet-name>
      <url-pattern>*.groovy</url-pattern>
      <url-pattern>*.gdo</url-pattern>
    </servlet-mapping>
 

The URL pattern does not require the "*.groovy" mapping. You can, for example, make it more Struts-like but groovy by making your mapping "*.gdo".

author:
Sam Pullara
author:
Mark Turansky (markturansky at hotmail.com)
author:
Guillaume Laforge
author:
Christian Stein
author:
Marcel Overdijk
see:
ServletBinding


Field Summary
 
Fields inherited from class AbstractHttpServlet
encoding, reflection, resourceNameMatcher, resourceNameReplaceAll, resourceNameReplacement, servletContext, verbose
 
Constructor Summary
GroovyServlet()

 
Method Summary
protected GroovyScriptEngine createGroovyScriptEngine()

Hook method to setup the GroovyScriptEngine to use.

void init(ServletConfig config)

Initialize the GroovyServlet.

void service(HttpServletRequest request, HttpServletResponse response)

Handle web requests to the GroovyServlet

 
Methods inherited from class AbstractHttpServlet
getResourceConnection, getScriptUri, getScriptUriAsFile, init, setVariables
 
Methods inherited from class HttpServlet
service, log, log, init, init, destroy, getInitParameter, getInitParameterNames, getServletConfig, getServletContext, getServletInfo, getServletName, wait, wait, wait, hashCode, getClass, equals, toString, notify, notifyAll
 
Methods inherited from class GenericServlet
log, log, init, init, destroy, service, getInitParameter, getInitParameterNames, getServletConfig, getServletContext, getServletInfo, getServletName, wait, wait, wait, hashCode, getClass, equals, toString, notify, notifyAll
 
Methods inherited from class Object
wait, wait, wait, hashCode, getClass, equals, toString, notify, notifyAll
 

Constructor Detail

GroovyServlet

GroovyServlet()


 
Method Detail

createGroovyScriptEngine

protected GroovyScriptEngine createGroovyScriptEngine()
Hook method to setup the GroovyScriptEngine to use.
Subclasses may override this method to provide a custom engine.


init

public void init(ServletConfig config)
Initialize the GroovyServlet.
throws:
ServletException if this method encountered difficulties


service

public void service(HttpServletRequest request, HttpServletResponse response)
Handle web requests to the GroovyServlet


 

Copyright © 2003-2009 The Codehaus. All rights reserved.