Package: org.codehaus.groovy.grails.web.servlet

## [Java] Class GrailsDispatcherServlet

- org.codehaus.groovy.grails.web.servlet.GrailsDispatcherServlet

- Handles incoming requests for Grails.

  Loads the Spring configuration based on the Grails application in the parent application context.
  Authors:
    Steven Devijver
    Graeme Rocher
  Since:
    Jul 2, 2005

- - ### Field Summary

    Fields
    Modifiers | Name | Description
    --- | --- | ---
    `protected org.springframework.web.servlet.HandlerInterceptor[]` | `interceptors` |
    `protected org.springframework.web.servlet.ViewResolver` | `layoutViewResolver` |
    `protected org.springframework.web.multipart.MultipartResolver` | `multipartResolver` |
    `protected StackTraceFilterer` | `stackFilterer` |

  - Inherited fields
    Fields inherited from class | Fields
    --- | ---
    `class org.springframework.web.servlet.DispatcherServlet` | `MULTIPART_RESOLVER_BEAN_NAME, LOCALE_RESOLVER_BEAN_NAME, THEME_RESOLVER_BEAN_NAME, HANDLER_MAPPING_BEAN_NAME, HANDLER_ADAPTER_BEAN_NAME, HANDLER_EXCEPTION_RESOLVER_BEAN_NAME, REQUEST_TO_VIEW_NAME_TRANSLATOR_BEAN_NAME, VIEW_RESOLVER_BEAN_NAME, FLASH_MAP_MANAGER_BEAN_NAME, WEB_APPLICATION_CONTEXT_ATTRIBUTE, LOCALE_RESOLVER_ATTRIBUTE, THEME_RESOLVER_ATTRIBUTE, THEME_SOURCE_ATTRIBUTE, INPUT_FLASH_MAP_ATTRIBUTE, OUTPUT_FLASH_MAP_ATTRIBUTE, FLASH_MAP_MANAGER_ATTRIBUTE, PAGE_NOT_FOUND_LOG_CATEGORY, DEFAULT_NAMESPACE_SUFFIX, DEFAULT_CONTEXT_CLASS, SERVLET_CONTEXT_PREFIX`
    `class org.springframework.web.servlet.FrameworkServlet` | `DEFAULT_NAMESPACE_SUFFIX, DEFAULT_CONTEXT_CLASS, SERVLET_CONTEXT_PREFIX`

  - ### Constructor Summary

    Constructors
    Constructor and description
    `GrailsDispatcherServlet ()` Constructor.

  - ### Methods Summary

    Methods
    Type | Name and description
    --- | ---
    `protected org.springframework.web.context.request.ServletRequestAttributes` | `buildRequestAttributes(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, org.springframework.web.context.request.RequestAttributes previousAttributes)`
    `protected javax.servlet.http.HttpServletRequest` | `checkMultipart(javax.servlet.http.HttpServletRequest request)` Convert the request into a multipart request.
    `protected void` | `copyParamsFromPreviousRequest(org.springframework.web.context.request.RequestAttributes previousRequestAttributes, GrailsWebRequest requestAttributes)`
    `protected void` | `createStackTraceFilterer()`
    `protected org.springframework.web.context.WebApplicationContext` | `createWebApplicationContext(org.springframework.web.context.WebApplicationContext parent)`
    `void` | `destroy()`
    `protected void` | `doDispatch(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response)`
    `protected org.springframework.web.servlet.HandlerInterceptor[]` | `establishInterceptors(org.springframework.web.context.WebApplicationContext webContext)` Evalutes the given WebApplicationContext for all HandlerInterceptor and WebRequestInterceptor instances
    `org.springframework.web.servlet.HandlerExecutionChain` | `getHandler(javax.servlet.http.HttpServletRequest request)`
    `protected void` | `initFrameworkServlet()`
    `protected void` | `initStrategies(org.springframework.context.ApplicationContext context)`
    `void` | `setApplication(GrailsApplication application)` Dependency injection for the application.
    `protected void` | `triggerAfterCompletion(org.springframework.web.servlet.HandlerExecutionChain mappedHandler, int interceptorIndex, javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, java.lang.Exception ex)` Trigger afterCompletion callbacks on the mapped HandlerInterceptors.
    `protected javax.servlet.http.HttpServletResponse` | `useWrappedOrOriginalResponse(javax.servlet.http.HttpServletResponse response)`

  - ### Inherited Methods Summary

    Inherited Methods
    Methods inherited from class | Name
    --- | ---
    `class org.springframework.web.servlet.DispatcherServlet` | `org.springframework.web.servlet.DispatcherServlet#setDetectAllHandlerMappings(boolean), org.springframework.web.servlet.DispatcherServlet#setDetectAllHandlerAdapters(boolean), org.springframework.web.servlet.DispatcherServlet#setDetectAllHandlerExceptionResolvers(boolean), org.springframework.web.servlet.DispatcherServlet#setDetectAllViewResolvers(boolean), org.springframework.web.servlet.DispatcherServlet#setThrowExceptionIfNoHandlerFound(boolean), org.springframework.web.servlet.DispatcherServlet#setCleanupAfterInclude(boolean), org.springframework.web.servlet.DispatcherServlet#getMultipartResolver(), org.springframework.web.servlet.DispatcherServlet#getThemeSource(), org.springframework.web.servlet.DispatcherServlet#destroy(), org.springframework.web.servlet.DispatcherServlet#setContextAttribute(java.lang.String), org.springframework.web.servlet.DispatcherServlet#setContextClass(java.lang.Class), org.springframework.web.servlet.DispatcherServlet#getContextClass(), org.springframework.web.servlet.DispatcherServlet#setContextId(java.lang.String), org.springframework.web.servlet.DispatcherServlet#getContextId(), org.springframework.web.servlet.DispatcherServlet#setContextConfigLocation(java.lang.String), org.springframework.web.servlet.DispatcherServlet#getContextConfigLocation(), org.springframework.web.servlet.DispatcherServlet#setContextInitializers([Lorg.springframework.context.ApplicationContextInitializer;), org.springframework.web.servlet.DispatcherServlet#setContextInitializerClasses(java.lang.String), org.springframework.web.servlet.DispatcherServlet#setPublishContext(boolean), org.springframework.web.servlet.DispatcherServlet#setPublishEvents(boolean), org.springframework.web.servlet.DispatcherServlet#setThreadContextInheritable(boolean), org.springframework.web.servlet.DispatcherServlet#setDispatchOptionsRequest(boolean), org.springframework.web.servlet.DispatcherServlet#setDispatchTraceRequest(boolean), org.springframework.web.servlet.DispatcherServlet#getServletContextAttributeName(), org.springframework.web.servlet.DispatcherServlet#refresh(), org.springframework.web.servlet.DispatcherServlet#getNamespace(), org.springframework.web.servlet.DispatcherServlet#setNamespace(java.lang.String), org.springframework.web.servlet.DispatcherServlet#getWebApplicationContext(), org.springframework.web.servlet.DispatcherServlet#setApplicationContext(org.springframework.context.ApplicationContext), org.springframework.web.servlet.DispatcherServlet#getContextAttribute(), org.springframework.web.servlet.DispatcherServlet#onApplicationEvent(org.springframework.context.event.ContextRefreshedEvent), org.springframework.web.servlet.DispatcherServlet#init(), org.springframework.web.servlet.DispatcherServlet#getEnvironment(), org.springframework.web.servlet.DispatcherServlet#getEnvironment(), org.springframework.web.servlet.DispatcherServlet#setEnvironment(org.springframework.core.env.Environment), org.springframework.web.servlet.DispatcherServlet#getServletContext(), org.springframework.web.servlet.DispatcherServlet#getServletName(), org.springframework.web.servlet.DispatcherServlet#service(javax.servlet.ServletRequest, javax.servlet.ServletResponse), org.springframework.web.servlet.DispatcherServlet#log(java.lang.String, java.lang.Throwable), org.springframework.web.servlet.DispatcherServlet#log(java.lang.String), org.springframework.web.servlet.DispatcherServlet#init(javax.servlet.ServletConfig), org.springframework.web.servlet.DispatcherServlet#getServletConfig(), org.springframework.web.servlet.DispatcherServlet#getServletInfo(), org.springframework.web.servlet.DispatcherServlet#getInitParameter(java.lang.String), org.springframework.web.servlet.DispatcherServlet#getInitParameterNames(), org.springframework.web.servlet.DispatcherServlet#wait(long, int), org.springframework.web.servlet.DispatcherServlet#wait(long), org.springframework.web.servlet.DispatcherServlet#wait(), org.springframework.web.servlet.DispatcherServlet#equals(java.lang.Object), org.springframework.web.servlet.DispatcherServlet#toString(), org.springframework.web.servlet.DispatcherServlet#hashCode(), org.springframework.web.servlet.DispatcherServlet#getClass(), org.springframework.web.servlet.DispatcherServlet#notify(), org.springframework.web.servlet.DispatcherServlet#notifyAll()`
    `class org.springframework.web.servlet.FrameworkServlet` | `org.springframework.web.servlet.FrameworkServlet#destroy(), org.springframework.web.servlet.FrameworkServlet#setContextAttribute(java.lang.String), org.springframework.web.servlet.FrameworkServlet#setContextClass(java.lang.Class), org.springframework.web.servlet.FrameworkServlet#getContextClass(), org.springframework.web.servlet.FrameworkServlet#setContextId(java.lang.String), org.springframework.web.servlet.FrameworkServlet#getContextId(), org.springframework.web.servlet.FrameworkServlet#setContextConfigLocation(java.lang.String), org.springframework.web.servlet.FrameworkServlet#getContextConfigLocation(), org.springframework.web.servlet.FrameworkServlet#setContextInitializers([Lorg.springframework.context.ApplicationContextInitializer;), org.springframework.web.servlet.FrameworkServlet#setContextInitializerClasses(java.lang.String), org.springframework.web.servlet.FrameworkServlet#setPublishContext(boolean), org.springframework.web.servlet.FrameworkServlet#setPublishEvents(boolean), org.springframework.web.servlet.FrameworkServlet#setThreadContextInheritable(boolean), org.springframework.web.servlet.FrameworkServlet#setDispatchOptionsRequest(boolean), org.springframework.web.servlet.FrameworkServlet#setDispatchTraceRequest(boolean), org.springframework.web.servlet.FrameworkServlet#getServletContextAttributeName(), org.springframework.web.servlet.FrameworkServlet#refresh(), org.springframework.web.servlet.FrameworkServlet#getNamespace(), org.springframework.web.servlet.FrameworkServlet#setNamespace(java.lang.String), org.springframework.web.servlet.FrameworkServlet#getWebApplicationContext(), org.springframework.web.servlet.FrameworkServlet#setApplicationContext(org.springframework.context.ApplicationContext), org.springframework.web.servlet.FrameworkServlet#getContextAttribute(), org.springframework.web.servlet.FrameworkServlet#onApplicationEvent(org.springframework.context.event.ContextRefreshedEvent), org.springframework.web.servlet.FrameworkServlet#init(), org.springframework.web.servlet.FrameworkServlet#getEnvironment(), org.springframework.web.servlet.FrameworkServlet#getEnvironment(), org.springframework.web.servlet.FrameworkServlet#setEnvironment(org.springframework.core.env.Environment), org.springframework.web.servlet.FrameworkServlet#getServletContext(), org.springframework.web.servlet.FrameworkServlet#getServletName(), org.springframework.web.servlet.FrameworkServlet#service(javax.servlet.ServletRequest, javax.servlet.ServletResponse), org.springframework.web.servlet.FrameworkServlet#log(java.lang.String, java.lang.Throwable), org.springframework.web.servlet.FrameworkServlet#log(java.lang.String), org.springframework.web.servlet.FrameworkServlet#init(javax.servlet.ServletConfig), org.springframework.web.servlet.FrameworkServlet#getServletConfig(), org.springframework.web.servlet.FrameworkServlet#getServletInfo(), org.springframework.web.servlet.FrameworkServlet#getInitParameter(java.lang.String), org.springframework.web.servlet.FrameworkServlet#getInitParameterNames(), org.springframework.web.servlet.FrameworkServlet#wait(long, int), org.springframework.web.servlet.FrameworkServlet#wait(long), org.springframework.web.servlet.FrameworkServlet#wait(), org.springframework.web.servlet.FrameworkServlet#equals(java.lang.Object), org.springframework.web.servlet.FrameworkServlet#toString(), org.springframework.web.servlet.FrameworkServlet#hashCode(), org.springframework.web.servlet.FrameworkServlet#getClass(), org.springframework.web.servlet.FrameworkServlet#notify(), org.springframework.web.servlet.FrameworkServlet#notifyAll()`

- - ### Field Detail

    - #### protected org.springframework.web.servlet.HandlerInterceptor[] interceptors

    - #### protected org.springframework.web.servlet.ViewResolver layoutViewResolver

    - #### protected org.springframework.web.multipart.MultipartResolver multipartResolver

    - #### protected StackTraceFilterer stackFilterer

  - ### Constructor Detail

    - #### public GrailsDispatcherServlet()

      Constructor.

  - ### Method Detail

    - #### @java.lang.Override protected org.springframework.web.context.request.ServletRequestAttributes buildRequestAttributes(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, org.springframework.web.context.request.RequestAttributes previousAttributes)

    - #### @java.lang.Override protected javax.servlet.http.HttpServletRequest checkMultipart(javax.servlet.http.HttpServletRequest request)

      Convert the request into a multipart request. If no multipart resolver is set, simply use the existing request.

      Parameters:
        `request` - current HTTP request
      Returns:
        the processed request (multipart wrapper if necessary)

    - #### @java.lang.SuppressWarnings({ "unchecked", "rawtypes" }) protected void copyParamsFromPreviousRequest(org.springframework.web.context.request.RequestAttributes previousRequestAttributes, GrailsWebRequest requestAttributes)

    - #### protected void createStackTraceFilterer()

    - #### @java.lang.Override protected org.springframework.web.context.WebApplicationContext createWebApplicationContext(org.springframework.web.context.WebApplicationContext parent)

    - #### @java.lang.Override public void destroy()

    - #### @java.lang.Override protected void doDispatch(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response)

    - #### protected org.springframework.web.servlet.HandlerInterceptor[] establishInterceptors(org.springframework.web.context.WebApplicationContext webContext)

      Evalutes the given WebApplicationContext for all HandlerInterceptor and WebRequestInterceptor instances

      Parameters:
        `webContext` - The WebApplicationContext
      Returns:
        An array of HandlerInterceptor instances

    - #### @java.lang.Override public org.springframework.web.servlet.HandlerExecutionChain getHandler(javax.servlet.http.HttpServletRequest request)

    - #### @java.lang.Override protected void initFrameworkServlet()

    - #### @java.lang.Override protected void initStrategies(org.springframework.context.ApplicationContext context)

    - #### public void setApplication(GrailsApplication application)

      Dependency injection for the application.

      Parameters:
        `application` - the application

    - #### protected void triggerAfterCompletion(org.springframework.web.servlet.HandlerExecutionChain mappedHandler, int interceptorIndex, javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, java.lang.Exception ex)

      Trigger afterCompletion callbacks on the mapped HandlerInterceptors. Will just invoke afterCompletion for all interceptors whose preHandle invocation has successfully completed and returned true.

      Parameters:
        `mappedHandler` - the mapped HandlerExecutionChain
        `interceptorIndex` - index of last interceptor that successfully completed
        `ex` - Exception thrown on handler execution, or `null` if none
      See Also:
        org.springframework.web.servlet.HandlerInterceptor#afterCompletion

    - #### protected javax.servlet.http.HttpServletResponse useWrappedOrOriginalResponse(javax.servlet.http.HttpServletResponse response)