Package: grails.util

## [Java] Class GrailsWebUtil

- grails.util.GrailsWebUtil

-     @java.lang.SuppressWarnings("rawtypes")
      public class GrailsWebUtil
      extends java.lang.Object

  Utility methods for clients using the web framework.

  Authors:
    Graeme Rocher
  Since:
    0.4

- - ### Field Summary

    Fields
    Modifiers | Name | Description
    --- | --- | ---
    `private static java.lang.String` | `CHARSET_ATTRIBUTE` |
    `private static java.util.regex.Pattern` | `CHARSET_IN_CONTENT_TYPE_REGEXP` |
    `static java.lang.String` | `DEFAULT_ENCODING` |

  - ### Constructor Summary

    Constructors
    Constructor and description
    `private GrailsWebUtil ()`

  - ### Methods Summary

    Methods
    Type Params | Return Type | Name and description
    --- | --- | ---
    `` | `public static GrailsApplication` | `currentApplication()` Returns: The currently bound GrailsApplication instance
    `` | `public static java.util.Map` | `currentConfiguration()` Returns: The currently bound GrailsApplication instance
    `` | `public static java.lang.String` | `getContentType(java.lang.String name, java.lang.String encoding)`
    `` | `public static groovy.lang.GroovyObject` | `getControllerFromRequest(javax.servlet.http.HttpServletRequest request)` Obtains the currently executing controller from the given request if any.
    `` | `public static java.lang.String` | `getUriFromRequest(javax.servlet.http.HttpServletRequest request)` Retrieves the URI from the request from either the include attribute or the request.getRequestURI() method.
    `` | `public static GrailsApplication` | `lookupApplication(javax.servlet.ServletContext servletContext)` Looks up a GrailsApplication instance from the ServletContext.

  - ### Inherited Methods Summary

    Inherited Methods
    Methods inherited from class | Name
    --- | ---
    `class java.lang.Object` | `java.lang.Object#wait(long), java.lang.Object#wait(long, int), java.lang.Object#wait(), java.lang.Object#equals(java.lang.Object), java.lang.Object#toString(), java.lang.Object#hashCode(), java.lang.Object#getClass(), java.lang.Object#notify(), java.lang.Object#notifyAll()`

- - ### Field Detail

    - #### private static final java.lang.String CHARSET_ATTRIBUTE

    - #### private static final java.util.regex.Pattern CHARSET_IN_CONTENT_TYPE_REGEXP

    - #### public static final java.lang.String DEFAULT_ENCODING

  - ### Constructor Detail

    - #### private GrailsWebUtil()

  - ### Method Detail

    - #### public static GrailsApplication currentApplication()

      Returns:
        The currently bound GrailsApplication instance
      Since:
        2.0

    - #### public static java.util.Map currentConfiguration()

      Returns:
        The currently bound GrailsApplication instance
      Since:
        2.0

    - #### public static java.lang.String getContentType(java.lang.String name, java.lang.String encoding)

    - #### public static groovy.lang.GroovyObject getControllerFromRequest(javax.servlet.http.HttpServletRequest request)

      Obtains the currently executing controller from the given request if any.

      Parameters:
        `request` - The request object
      Returns:
        The controller or null

    - #### public static java.lang.String getUriFromRequest(javax.servlet.http.HttpServletRequest request)

      Retrieves the URI from the request from either the include attribute or the request.getRequestURI() method.

      Parameters:
        `request` - The HttpServletRequest instance
      Returns:
        The String URI

    - #### public static GrailsApplication lookupApplication(javax.servlet.ServletContext servletContext)

      Looks up a GrailsApplication instance from the ServletContext.

      Parameters:
        `servletContext` - The ServletContext
      Returns:
        A GrailsApplication or null if there isn't one