Package groovy.servlet
Class GroovyServlet
- java.lang.Object
- 
- javax.servlet.GenericServlet
- 
- javax.servlet.http.HttpServlet
- 
- groovy.servlet.AbstractHttpServlet
- 
- groovy.servlet.GroovyServlet
 
 
 
 
- 
- All Implemented Interfaces:
- ResourceConnector,- java.io.Serializable,- Servlet,- ServletConfig
 
 public class GroovyServlet extends AbstractHttpServlet This servlet will run Groovy scripts as Groovlets. Groovlets are scripts with these objects implicit in their scope:- request - the HttpServletRequest
- response - the HttpServletResponse
- application - the ServletContext associated with the servlet
- session - the HttpSession associated with the HttpServletRequest
- out - the PrintWriter associated with the ServletRequest
 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". - See Also:
- ServletBinding, Serialized Form
 
- 
- 
Field Summary- 
Fields inherited from class groovy.servlet.AbstractHttpServletCONTENT_TYPE_TEXT_HTML, encoding, INC_PATH_INFO, INC_REQUEST_URI, INC_SERVLET_PATH, INIT_PARAM_RESOURCE_NAME_REGEX, INIT_PARAM_RESOURCE_NAME_REGEX_FLAGS, namePrefix, reflection, resourceNamePattern, resourceNameReplaceAll, resourceNameReplacement, servletContext, verbose
 
- 
 - 
Constructor SummaryConstructors Constructor Description GroovyServlet()
 - 
Method SummaryAll Methods Instance Methods Concrete Methods Modifier and Type Method Description protected GroovyScriptEnginecreateGroovyScriptEngine()Hook method to setup the GroovyScriptEngine to use.
 Subclasses may override this method to provide a custom engine.voidinit(ServletConfig config)Initialize the GroovyServlet.voidservice(HttpServletRequest request, HttpServletResponse response)Handle web requests to the GroovyServlet- 
Methods inherited from class groovy.servlet.AbstractHttpServletapplyResourceNameMatcher, generateNamePrefixOnce, getResourceConnection, getScriptUri, getScriptUriAsFile, removeNamePrefix, setVariables
 - 
Methods inherited from class javax.servlet.http.HttpServletdoDelete, doGet, doHead, doOptions, doPost, doPut, doTrace, getLastModified, service
 - 
Methods inherited from class javax.servlet.GenericServletdestroy, getInitParameter, getInitParameterNames, getServletConfig, getServletContext, getServletInfo, getServletName, init, log, log
 
- 
 
- 
- 
- 
Method Detail- 
initpublic void init(ServletConfig config) throws ServletException Initialize the GroovyServlet.- Specified by:
- initin interface- Servlet
- Overrides:
- initin class- AbstractHttpServlet
- Parameters:
- config- the servlet configuration provided by the container
- Throws:
- ServletException- if this method encountered difficulties
 
 - 
servicepublic void service(HttpServletRequest request, HttpServletResponse response) throws java.io.IOException Handle web requests to the GroovyServlet- Overrides:
- servicein class- HttpServlet
- Throws:
- java.io.IOException
 
 - 
createGroovyScriptEngineprotected GroovyScriptEngine createGroovyScriptEngine() Hook method to setup the GroovyScriptEngine to use.
 Subclasses may override this method to provide a custom engine.
 
- 
 
-