Save This Page
Home » groovy-src-1.6.3 » groovy » servlet » [javadoc | source]
groovy.servlet
public class: GroovyServlet [javadoc | source]
java.lang.Object
   javax.servlet.GenericServlet
      javax.servlet.http.HttpServlet
         groovy.servlet.AbstractHttpServlet
            groovy.servlet.GroovyServlet

All Implemented Interfaces:
    ResourceConnector, Serializable, Servlet, ServletConfig

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".

Fields inherited from groovy.servlet.AbstractHttpServlet:
CONTENT_TYPE_TEXT_HTML,  INC_PATH_INFO,  INC_REQUEST_URI,  INC_SERVLET_PATH,  servletContext,  resourceNameMatcher,  resourceNameReplacement,  resourceNameReplaceAll,  verbose,  encoding,  reflection
Method from groovy.servlet.GroovyServlet Summary:
createGroovyScriptEngine,   init,   service
Methods from groovy.servlet.AbstractHttpServlet:
getResourceConnection,   getScriptUri,   getScriptUriAsFile,   init,   setVariables
Methods from javax.servlet.http.HttpServlet:
service
Methods from javax.servlet.GenericServlet:
destroy,   getInitParameter,   getInitParameterNames,   getServletConfig,   getServletContext,   getServletInfo,   getServletName,   init,   init,   log,   log,   service
Methods from java.lang.Object:
equals,   getClass,   hashCode,   notify,   notifyAll,   toString,   wait,   wait,   wait
Method from groovy.servlet.GroovyServlet Detail:
 protected GroovyScriptEngine createGroovyScriptEngine() 
    Hook method to setup the GroovyScriptEngine to use.
    Subclasses may override this method to provide a custom engine.
 public  void init(ServletConfig config) throws ServletException 
    Initialize the GroovyServlet.
 public  void service(HttpServletRequest request,
    HttpServletResponse response) throws IOException 
    Handle web requests to the GroovyServlet