Package grails.util

Class GrailsWebUtil


  • public class GrailsWebUtil
    extends java.lang.Object
    Utility methods for clients using the web framework.
    Since:
    0.4
    • Field Summary

      Fields 
      Modifier and Type Field Description
      static java.lang.String DEFAULT_ENCODING  
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static grails.core.GrailsApplication currentApplication()  
      static java.util.Map currentConfiguration()  
      static java.lang.String getContentType​(java.lang.String name, java.lang.String encoding)  
      static groovy.lang.GroovyObject getControllerFromRequest​(javax.servlet.http.HttpServletRequest request)
      Obtains the currently executing controller from the given request if any.
      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.
      static grails.core.GrailsApplication lookupApplication​(javax.servlet.ServletContext servletContext)
      Looks up a GrailsApplication instance from the ServletContext.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • DEFAULT_ENCODING

        public static final java.lang.String DEFAULT_ENCODING
        See Also:
        Constant Field Values
    • Method Detail

      • lookupApplication

        public static grails.core.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
      • currentApplication

        public static grails.core.GrailsApplication currentApplication()
        Returns:
        The currently bound GrailsApplication instance
        Since:
        2.0
      • currentConfiguration

        public static java.util.Map currentConfiguration()
        Returns:
        The currently bound GrailsApplication instance
        Since:
        2.0
      • getUriFromRequest

        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
      • getControllerFromRequest

        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
      • getContentType

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