org.codehaus.groovy.grails.web.pages
Class GroovyPagesServlet

java.lang.Object
  extended by javax.servlet.GenericServlet
      extended by javax.servlet.http.HttpServlet
          extended by org.springframework.web.servlet.HttpServletBean
              extended by org.springframework.web.servlet.FrameworkServlet
                  extended by org.codehaus.groovy.grails.web.pages.GroovyPagesServlet
All Implemented Interfaces:
Serializable, Servlet, ServletConfig

public class GroovyPagesServlet
extends FrameworkServlet

NOTE: Based on work done by on the GSP standalone project (https://gsp.dev.java.net/) Main servlet class. Example usage in web.xml: GroovyPagesServlet org.codehaus.groovy.grails.web.pages.GroovyPagesServlet showSource 1 Allows developers to view the intermediade source code, when they pass a showSource argument in the URL (eg /edit/list?showSource=true.

Author:
Troy Heninger, Graeme Rocher Date: Jan 10, 2004
See Also:
Serialized Form

Field Summary
static String EXCEPTION_MODEL_KEY
           
static String SERVLET_INSTANCE
           
 
Fields inherited from class org.springframework.web.servlet.FrameworkServlet
DEFAULT_CONTEXT_CLASS, DEFAULT_NAMESPACE_SUFFIX, SERVLET_CONTEXT_PREFIX
 
Fields inherited from class org.springframework.web.servlet.HttpServletBean
logger
 
Constructor Summary
GroovyPagesServlet()
           
 
Method Summary
protected  Writer createResponseWriter(HttpServletResponse response)
          Creates a response writer for the given response object
protected  void doService(HttpServletRequest request, HttpServletResponse response)
           
protected  void handleException(HttpServletRequest request, HttpServletResponse response, Exception exception, Writer out, GroovyPagesTemplateEngine engine)
          Performs exception handling by attempting to render the Errors view
protected  void initFrameworkServlet()
           
protected  void renderPageWithEngine(GroovyPagesTemplateEngine engine, HttpServletRequest request, HttpServletResponse response, groovy.text.Template template)
          Attempts to render the page with the given arguments
 
Methods inherited from class org.springframework.web.servlet.FrameworkServlet
buildLocaleContext, createWebApplicationContext, createWebApplicationContext, destroy, doDelete, doGet, doOptions, doPost, doPut, doTrace, findWebApplicationContext, getContextAttribute, getContextClass, getContextConfigLocation, getNamespace, getServletContextAttributeName, getUsernameForRequest, getWebApplicationContext, initServletBean, initWebApplicationContext, onApplicationEvent, onRefresh, postProcessWebApplicationContext, processRequest, refresh, setContextAttribute, setContextClass, setContextConfigLocation, setDispatchOptionsRequest, setDispatchTraceRequest, setNamespace, setPublishContext, setPublishEvents, setThreadContextInheritable
 
Methods inherited from class org.springframework.web.servlet.HttpServletBean
addRequiredProperty, getServletContext, getServletName, init, initBeanWrapper
 
Methods inherited from class javax.servlet.http.HttpServlet
doHead, getLastModified, service, service
 
Methods inherited from class javax.servlet.GenericServlet
getInitParameter, getInitParameterNames, getServletConfig, getServletInfo, init, log, log
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

EXCEPTION_MODEL_KEY

public static final String EXCEPTION_MODEL_KEY
See Also:
Constant Field Values

SERVLET_INSTANCE

public static final String SERVLET_INSTANCE
See Also:
Constant Field Values
Constructor Detail

GroovyPagesServlet

public GroovyPagesServlet()
Method Detail

initFrameworkServlet

protected void initFrameworkServlet()
                             throws ServletException,
                                    BeansException
Overrides:
initFrameworkServlet in class FrameworkServlet
Throws:
ServletException
BeansException

doService

protected void doService(HttpServletRequest request,
                         HttpServletResponse response)
                  throws Exception
Specified by:
doService in class FrameworkServlet
Throws:
Exception

renderPageWithEngine

protected void renderPageWithEngine(GroovyPagesTemplateEngine engine,
                                    HttpServletRequest request,
                                    HttpServletResponse response,
                                    groovy.text.Template template)
                             throws IOException,
                                    ServletException
Attempts to render the page with the given arguments

Parameters:
engine - The GroovyPagesTemplateEngine to use
request - The HttpServletRequest
response - The HttpServletResponse
template - The template
Throws:
IOException - Thrown when an I/O exception occurs rendering the page
ServletException - Thrown when an exception occurs in the servlet environment

handleException

protected void handleException(HttpServletRequest request,
                               HttpServletResponse response,
                               Exception exception,
                               Writer out,
                               GroovyPagesTemplateEngine engine)
                        throws ServletException,
                               IOException
Performs exception handling by attempting to render the Errors view

Parameters:
request -
response -
exception - The exception that occured
out - The Writer
engine - The GSP engine @throws IOException Thrown when an I/O exception occurs rendering the page
Throws:
ServletException - Thrown when an exception occurs in the servlet environment
IOException

createResponseWriter

protected Writer createResponseWriter(HttpServletResponse response)
Creates a response writer for the given response object

Parameters:
response - The HttpServletResponse
Returns:
The created java.io.Writer


Copyright (c) 2005-2009 The Grails project