Package org.apache.myfaces.util
Class ExternalContextUtils
- java.lang.Object
- 
- org.apache.myfaces.util.ExternalContextUtils
 
- 
 public final class ExternalContextUtils extends Object 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 SummaryAll Methods Static Methods Concrete Methods Modifier and Type Method Description static jakarta.servlet.http.HttpServletRequestgetHttpServletRequest(ExternalContext ec)Returns an HttpServletRequest if one exists on the externalContext or null if it does not.static jakarta.servlet.http.HttpServletResponsegetHttpServletResponse(ExternalContext ec)Returns an HttpServletResponse if one exists on the externalContext or null if it does not.static jakarta.servlet.http.HttpServletResponsegetHttpServletResponse(Object response)Trys to obtain a HttpServletResponse from the Response.static booleanisHttpServletRequest(ExternalContext ec)Returns wherther of not this external context represents a true HttpServletRequest or not.static booleanisPortlet(ExternalContext ec)This is a convenience function designed to perform a quick check of the currentExternalContext.
 
- 
- 
- 
Method Detail- 
isPortletpublic static boolean isPortlet(ExternalContext ec) This is a convenience function designed to perform a quick check of the currentExternalContext.- Parameters:
- ec- the current external context
- Returns:
- trueif the current- ExternalContextis a Porlet.
 
 - 
isHttpServletRequestpublic static boolean isHttpServletRequest(ExternalContext ec) 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 trueif the current request is an HttpServletRequest
 
 - 
getHttpServletResponsepublic static jakarta.servlet.http.HttpServletResponse getHttpServletResponse(ExternalContext ec) 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
 
 - 
getHttpServletRequestpublic static jakarta.servlet.http.HttpServletRequest getHttpServletRequest(ExternalContext ec) 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
 
 - 
getHttpServletResponsepublic static jakarta.servlet.http.HttpServletResponse getHttpServletResponse(Object response) 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
 
 
- 
 
-