Package org.apache.myfaces.util
Class ExternalContextUtils
java.lang.Object
org.apache.myfaces.util.ExternalContextUtils
This provides some functionality for determining some things about the
native request object that is not provided by Faces. This class is useful
for use in places where Portlet API's may or may not be present and can
also provide access to some request-specific items which are not available on
the Faces ExternalContext. If portlet API's are not present, this class simply
handles the Servlet Request type.
-
Method Summary
Modifier and TypeMethodDescriptionstatic jakarta.servlet.http.HttpServletRequest
Returns an HttpServletRequest if one exists on the externalContext or null if it does not.static jakarta.servlet.http.HttpServletResponse
Returns an HttpServletResponse if one exists on the externalContext or null if it does not.static jakarta.servlet.http.HttpServletResponse
getHttpServletResponse
(Object response) Trys to obtain a HttpServletResponse from the Response.static boolean
Returns wherther of not this external context represents a true HttpServletRequest or not.static boolean
This is a convenience function designed to perform a quick check of the currentExternalContext
.
-
Method Details
-
isPortlet
This is a convenience function designed to perform a quick check of the currentExternalContext
.- Parameters:
ec
- the current external context- Returns:
true
if the currentExternalContext
is a Porlet.
-
isHttpServletRequest
Returns wherther of not this external context represents a true HttpServletRequest or not. Some portal containers implement the PortletRequest/Response objects as HttpServletRequestWrappers, and those objects should not be treated as an HttpServlerRequest. As such, this method first tests to see if the request is a portlet request and, if not, then tests to see if the request is an instanceof HttpServletRequest.- Parameters:
ec
- the current external context- Returns:
- a boolean value of
true
if the current request is an HttpServletRequest
-
getHttpServletResponse
Returns an HttpServletResponse if one exists on the externalContext or null if it does not. Please note that some portal environments implement the PortletRequest and Response objects as HttpServletRequest/Response objects. This method handles these types of requests properly and will therefore return null in portal environments.- Parameters:
ec
-- Returns:
- an HttpServletResponse if we have one or null if we do not
-
getHttpServletRequest
Returns an HttpServletRequest if one exists on the externalContext or null if it does not. Please note that some portal environments implement the PortletRequest and Response objects as HttpServletRequest/Response objects. This method handles these types of requests properly and will therefore return null in portal environments.- Parameters:
ec
-- Returns:
- an HttpServletResponse if we have one or null if we do not
-
getHttpServletResponse
Trys to obtain a HttpServletResponse from the Response. Note that this method also trys to unwrap any ServletResponseWrapper in order to retrieve a valid HttpServletResponse.- Parameters:
response
-- Returns:
- if found, the HttpServletResponse, null otherwise
-