org.springframework.web.servlet.support
Class RequestContextUtils

java.lang.Object
  extended byorg.springframework.web.servlet.support.RequestContextUtils

public abstract class RequestContextUtils
extends java.lang.Object

Utility class for easy access to various request-specific state, set by the DispatcherServlet.

Since:
03.03.2003
Author:
Juergen Hoeller

Constructor Summary
RequestContextUtils()
           
 
Method Summary
static java.util.Locale getLocale(javax.servlet.http.HttpServletRequest request)
          Retrieves the current locale from the given request, using the LocaleResolver bound to the request by the DispatcherServlet.
static LocaleResolver getLocaleResolver(javax.servlet.http.HttpServletRequest request)
          Return the LocaleResolver that has been bound to the request by the DispatcherServlet.
static MultipartResolver getMultipartResolver(javax.servlet.http.HttpServletRequest request)
          Return the MultipartResolver that has been bound to the request by the DispatcherServlet.
static Theme getTheme(javax.servlet.http.HttpServletRequest request)
          Retrieves the current theme from the given request, using the ThemeResolver bound to the request by the DispatcherServlet, and the current WebApplicationContext.
static ThemeResolver getThemeResolver(javax.servlet.http.HttpServletRequest request)
          Return the ThemeResolver that has been bound to the request by the DispatcherServlet.
static WebApplicationContext getWebApplicationContext(javax.servlet.ServletRequest request)
          Look for the WebApplicationContext associated with the controller servlet that has initiated request processing.
static WebApplicationContext getWebApplicationContext(javax.servlet.ServletRequest request, javax.servlet.ServletContext servletContext)
          Look for the WebApplicationContext associated with the controller servlet that has initiated request processing, and for the global context if none was found associated with the current request.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

RequestContextUtils

public RequestContextUtils()
Method Detail

getWebApplicationContext

public static WebApplicationContext getWebApplicationContext(javax.servlet.ServletRequest request)
                                                      throws java.lang.IllegalStateException
Look for the WebApplicationContext associated with the controller servlet that has initiated request processing.

Parameters:
request - current HTTP request
Returns:
the request-specific web application context
Throws:
java.lang.IllegalStateException - if neither a servlet-specific nor global context has been found

getWebApplicationContext

public static WebApplicationContext getWebApplicationContext(javax.servlet.ServletRequest request,
                                                             javax.servlet.ServletContext servletContext)
                                                      throws java.lang.IllegalStateException
Look for the WebApplicationContext associated with the controller servlet that has initiated request processing, and for the global context if none was found associated with the current request. This method is useful to allow components outside our framework, such as JSP tag handlers, to access the most specific application context available.

Parameters:
request - current HTTP request
servletContext - current servlet context
Returns:
the request-specific or global web application context if no request-specific context has been set
Throws:
java.lang.IllegalStateException - if neither a servlet-specific nor global context has been found

getLocaleResolver

public static LocaleResolver getLocaleResolver(javax.servlet.http.HttpServletRequest request)
                                        throws java.lang.IllegalStateException
Return the LocaleResolver that has been bound to the request by the DispatcherServlet.

Parameters:
request - current HTTP request
Returns:
the current LocaleResolver
Throws:
java.lang.IllegalStateException - if no LocaleResolver has been found

getLocale

public static java.util.Locale getLocale(javax.servlet.http.HttpServletRequest request)
                                  throws java.lang.IllegalStateException
Retrieves the current locale from the given request, using the LocaleResolver bound to the request by the DispatcherServlet.

Parameters:
request - current HTTP request
Returns:
the current locale
Throws:
java.lang.IllegalStateException - if no LocaleResolver has been found

getThemeResolver

public static ThemeResolver getThemeResolver(javax.servlet.http.HttpServletRequest request)
                                      throws java.lang.IllegalStateException
Return the ThemeResolver that has been bound to the request by the DispatcherServlet.

Parameters:
request - current HTTP request
Returns:
the current ThemeResolver
Throws:
java.lang.IllegalStateException - if no ThemeResolver has been found

getTheme

public static Theme getTheme(javax.servlet.http.HttpServletRequest request)
                      throws java.lang.IllegalStateException
Retrieves the current theme from the given request, using the ThemeResolver bound to the request by the DispatcherServlet, and the current WebApplicationContext.

Parameters:
request - current HTTP request
Returns:
the current theme
Throws:
java.lang.IllegalStateException - if no ThemeResolver has been found

getMultipartResolver

public static MultipartResolver getMultipartResolver(javax.servlet.http.HttpServletRequest request)
Return the MultipartResolver that has been bound to the request by the DispatcherServlet.

Parameters:
request - current HTTP request
Returns:
the current MultipartResolver, or null if not a multipart request


Copyright (C) 2003-2004 The Spring Framework Project.