|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjavax.servlet.GenericServlet
javax.servlet.http.HttpServlet
groovy.servlet.GroovyServlet
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:
Groovy groovy.servlet.GroovyServlet Groovy *.groovy
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".
Whatever your mapping, the GroovyServlet will check to see if your URL ends with ".groovy" and, if it does not, it will strip your mapping and append ".groovy".
NOTE! The GroovyServlet only handles mappings of the *.* type, not the path-like type of /groovy/*
Field Summary | |
static java.lang.String |
GROOVY_EXTENSION
A constant for ".groovy" which gets appended to script paths as needed. |
private static GroovyScriptEngine |
gse
The script engine executing the Groovy scripts for this servlet |
private static java.lang.ClassLoader |
parent
The classloader associated with this servlet |
private javax.servlet.ServletContext |
sc
The context in which this servlet is executing |
Fields inherited from class javax.servlet.http.HttpServlet |
|
Fields inherited from class javax.servlet.GenericServlet |
|
Constructor Summary | |
GroovyServlet()
|
Method Summary | |
private java.lang.String |
getGroovyScriptPath(javax.servlet.http.HttpServletRequest request)
From the HttpServletRequest, parse the groovy script path using the URL, adding the extension ".groovy" as needed. |
java.net.URLConnection |
getResourceConnection(java.lang.String name)
Interface method for ResourceContainer. |
javax.servlet.ServletContext |
getServletContext()
Returns the ServletContext for this servlet |
void |
init(javax.servlet.ServletConfig config)
Initialize the GroovyServlet. |
void |
service(javax.servlet.ServletRequest request,
javax.servlet.ServletResponse response)
Handle web requests to the GroovyServlet |
Methods inherited from class javax.servlet.http.HttpServlet |
doDelete, doGet, doHead, doOptions, doPost, doPut, doTrace, getLastModified, service |
Methods inherited from class javax.servlet.GenericServlet |
destroy, getInitParameter, getInitParameterNames, getServletConfig, getServletInfo, getServletName, init, log, log |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
public static final java.lang.String GROOVY_EXTENSION
private javax.servlet.ServletContext sc
private static java.lang.ClassLoader parent
private static GroovyScriptEngine gse
Constructor Detail |
public GroovyServlet()
Method Detail |
public javax.servlet.ServletContext getServletContext()
getServletContext
in interface javax.servlet.ServletConfig
public void init(javax.servlet.ServletConfig config)
init
in interface javax.servlet.Servlet
public java.net.URLConnection getResourceConnection(java.lang.String name) throws ResourceException
getResourceConnection
in interface ResourceConnector
ResourceException
public void service(javax.servlet.ServletRequest request, javax.servlet.ServletResponse response) throws javax.servlet.ServletException, java.io.IOException
service
in interface javax.servlet.Servlet
javax.servlet.ServletException
java.io.IOException
private java.lang.String getGroovyScriptPath(javax.servlet.http.HttpServletRequest request)
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |