|
||||||||||
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.AbstractHttpServlet
groovy.servlet.GroovyServlet
public class 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:
<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".
ServletBinding
,
Serialized FormField Summary | |
---|---|
private GroovyScriptEngine |
gse
The script engine executing the Groovy scripts for this servlet |
Fields inherited from class groovy.servlet.AbstractHttpServlet |
---|
CONTENT_TYPE_TEXT_HTML, encoding, INC_PATH_INFO, INC_REQUEST_URI, INC_SERVLET_PATH, reflection, resourceNameMatcher, resourceNameReplaceAll, resourceNameReplacement, servletContext, verbose |
Constructor Summary | |
---|---|
GroovyServlet()
|
Method Summary | |
---|---|
protected GroovyScriptEngine |
createGroovyScriptEngine()
Hook method to setup the GroovyScriptEngine to use. Subclasses may override this method to provide a custom engine. |
void |
init(javax.servlet.ServletConfig config)
Initialize the GroovyServlet. |
void |
service(javax.servlet.http.HttpServletRequest request,
javax.servlet.http.HttpServletResponse response)
Handle web requests to the GroovyServlet |
Methods inherited from class groovy.servlet.AbstractHttpServlet |
---|
getResourceConnection, getScriptUri, getScriptUriAsFile, setVariables |
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, getServletContext, 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 |
---|
private GroovyScriptEngine gse
Constructor Detail |
---|
public GroovyServlet()
Method Detail |
---|
public void init(javax.servlet.ServletConfig config) throws javax.servlet.ServletException
init
in interface javax.servlet.Servlet
init
in class AbstractHttpServlet
config
- the servlet coniguration provided by the container
javax.servlet.ServletException
- if this method encountered difficultiespublic void service(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response) throws java.io.IOException
service
in class javax.servlet.http.HttpServlet
java.io.IOException
protected GroovyScriptEngine createGroovyScriptEngine()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |