Class ExternalContext
- java.lang.Object
-
- javax.faces.context.ExternalContext
-
- Direct Known Subclasses:
ExternalContextWrapper
public abstract class ExternalContext extends java.lang.ObjectThis class allows the Faces API to be unaware of the nature of its containing application environment. In particular, this class allows JavaServer Faces based appications to run in either a Servlet or a Portlet environment.
The documentation for this class only specifies the behavior for the Servlet implementation of
ExternalContext. The Portlet implementation ofExternalContextis specified under the revision of the Portlet Bridge Specification for JavaServer Faces JSR that corresponds to this version of the JSF specification. See the Preface of the "prose document", linked from the javadocs, for a reference.If a reference to an
ExternalContextis obtained during application startup or shutdown time, any method documented as "valid to call this method during application startup or shutdown" must be supported during application startup or shutdown time. The result of calling a method during application startup or shutdown time that does not have this designation is undefined.
-
-
Field Summary
Fields Modifier and Type Field Description static java.lang.StringBASIC_AUTHString identifier for BASIC authentication.static java.lang.StringCLIENT_CERT_AUTHString identifier for CLIENT_CERT authentication.static java.lang.StringDIGEST_AUTHString identifier for DIGEST authentication.static java.lang.StringFORM_AUTHString identifier for FORM authentication.
-
Constructor Summary
Constructors Constructor Description ExternalContext()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description voidaddResponseCookie(java.lang.String name, java.lang.String value, java.util.Map<java.lang.String,java.lang.Object> properties)Adds the cookie represented by the arguments to the response.voidaddResponseHeader(java.lang.String name, java.lang.String value)Add the given name and value to the response header.abstract voiddispatch(java.lang.String path)Dispatch a request to the specified resource to create output for this response.abstract java.lang.StringencodeActionURL(java.lang.String url)Return the input URL, after performing any rewriting needed to ensure that it will correctly identify an addressable action in the current application.java.lang.StringencodeBookmarkableURL(java.lang.String baseUrl, java.util.Map<java.lang.String,java.util.List<java.lang.String>> parameters)The purpose of this method is to generate a query string from the collection of Parameter objects provided by the parameters argument and append that query string to the baseUrl.abstract java.lang.StringencodeNamespace(java.lang.String name)Return the specified name, after prefixing it with a namespace that ensures that it will be unique within the context of a particular page.java.lang.StringencodePartialActionURL(java.lang.String url)Return the input URL, after performing any rewriting needed to ensure that it can be used in a partial page submission (ajax request) to correctly identify an addressable action in the current application.java.lang.StringencodeRedirectURL(java.lang.String baseUrl, java.util.Map<java.lang.String,java.util.List<java.lang.String>> parameters)The purpose of this method is to generate a query string from the collection of Parameter objects provided by the parameters argument and append that query string to the baseUrl.abstract java.lang.StringencodeResourceURL(java.lang.String url)Return the input URL, after performing any rewriting needed to ensure that it will correctly identify an addressable resource in the current application.java.lang.StringgetApplicationContextPath()Return the name of the container context for this application.abstract java.util.Map<java.lang.String,java.lang.Object>getApplicationMap()Return a mutableMaprepresenting the application scope attributes for the current application.abstract java.lang.StringgetAuthType()Return the name of the authentication scheme used to authenticate the current user, if any; otherwise, returnnull.ClientWindowgetClientWindow()Return theClientWindowset in a preceding call tosetClientWindow(javax.faces.lifecycle.ClientWindow), ornullif no such call has been made.abstract java.lang.ObjectgetContext()Return the application environment object instance for the current appication.java.lang.StringgetContextName()Return the name of the container context for this application.FlashgetFlash()Return the threadsafeFlashfor this application.abstract java.lang.StringgetInitParameter(java.lang.String name)Return the value of the specified application initialization parameter (if any).abstract java.util.MapgetInitParameterMap()Return an immutableMapwhose keys are the set of application initialization parameter names configured for this application, and whose values are the corresponding parameter values.java.lang.StringgetMimeType(java.lang.String file)Returns the MIME type of the specified file ornullif the MIME type is not known.java.lang.StringgetRealPath(java.lang.String path)Returns a String containing the real path for a given virtual path.abstract java.lang.StringgetRemoteUser()Return the login name of the user making the current request if any; otherwise, returnnull.abstract java.lang.ObjectgetRequest()Return the environment-specific object instance for the current request.java.lang.StringgetRequestCharacterEncoding()Return the character encoding currently being used to interpret this request.intgetRequestContentLength()Return the result of callinggetContentLenth()on theServletRequestinstance for this request.java.lang.StringgetRequestContentType()Return the MIME Content-Type for this request.abstract java.lang.StringgetRequestContextPath()Return the portion of the request URI that identifies the web application context for this request.abstract java.util.Map<java.lang.String,java.lang.Object>getRequestCookieMap()Return an immutableMapwhose keys are the set of cookie names included in the current request, and whose values (of typejavax.servlet.http.Cookie) are the first (or only) cookie for each cookie name returned by the underlying request.abstract java.util.Map<java.lang.String,java.lang.String>getRequestHeaderMap()Return an immutableMapwhose keys are the set of request header names included in the current request, and whose values (of type String) are the first (or only) value for each header name returned by the underlying request.abstract java.util.Map<java.lang.String,java.lang.String[]>getRequestHeaderValuesMap()Return an immutableMapwhose keys are the set of request header names included in the current request, and whose values (of type String[]) are all of the value for each header name returned by the underlying request.abstract java.util.LocalegetRequestLocale()Return the preferredLocalein which the client will accept content.abstract java.util.Iterator<java.util.Locale>getRequestLocales()Return anIteratorover the preferredLocales specified in the request, in decreasing order of preference.abstract java.util.Map<java.lang.String,java.lang.Object>getRequestMap()Return a mutableMaprepresenting the request scope attributes for the current application.abstract java.util.Map<java.lang.String,java.lang.String>getRequestParameterMap()Return an immutableMapwhose keys are the set of request parameters names included in the current request, and whose values (of type String) are the first (or only) value for each parameter name returned by the underlying request.abstract java.util.Iterator<java.lang.String>getRequestParameterNames()Return anIteratorover the names of all request parameters included in the current request.abstract java.util.Map<java.lang.String,java.lang.String[]>getRequestParameterValuesMap()Return an immutableMapwhose keys are the set of request parameters names included in the current request, and whose values (of type String[]) are all of the values for each parameter name returned by the underlying request.abstract java.lang.StringgetRequestPathInfo()Return the extra path information (if any) included in the request URI; otherwise, returnnull.java.lang.StringgetRequestScheme()Returns the name of the scheme used to make this request, for example, http, https, or ftp.java.lang.StringgetRequestServerName()Returns the host name of the server to which the request was sent.intgetRequestServerPort()Returns the port number to which the request was sent.abstract java.lang.StringgetRequestServletPath()Return the servlet path information (if any) included in the request URI; otherwise, returnnull.abstract java.net.URLgetResource(java.lang.String path)Return aURLfor the application resource mapped to the specified path, if it exists; otherwise, returnnull.abstract java.io.InputStreamgetResourceAsStream(java.lang.String path)Return anInputStreamfor an application resource mapped to the specified path, if it exists; otherwise, returnnull.abstract java.util.Set<java.lang.String>getResourcePaths(java.lang.String path)Return theSetof resource paths for all application resources whose resource path starts with the specified argument.abstract java.lang.ObjectgetResponse()Return the environment-specific object instance for the current response.intgetResponseBufferSize()Return the buffer size for the current response.java.lang.StringgetResponseCharacterEncoding()Returns the name of the character encoding (MIME charset) used for the body sent in this response.java.lang.StringgetResponseContentType()Return the MIME Content-Type for this response.java.io.OutputStreamgetResponseOutputStream()Returns anOutputStreamsuitable for writing binary data to the user-agent.java.io.WritergetResponseOutputWriter()Returns aWritersuitable for writing character data to the user-agent.abstract java.lang.ObjectgetSession(boolean create)If thecreateparameter istrue, create (if necessary) and return a session instance associated with the current request.java.lang.StringgetSessionId(boolean create)Return the id of the current session or the empty string if no session has been created and thecreateparameter isfalse.abstract java.util.Map<java.lang.String,java.lang.Object>getSessionMap()Return a mutableMaprepresenting the session scope attributes for the current application.intgetSessionMaxInactiveInterval()Returns the maximum time interval, in seconds, that the servlet container will keep this session open between client accesses.abstract java.security.PrincipalgetUserPrincipal()Return thePrincipalobject containing the name of the current authenticated user, if any; otherwise, returnnull.voidinvalidateSession()Invalidates this session then unbinds any objects bound to it.booleanisResponseCommitted()Check if the current response has been committed.booleanisSecure()Returns a boolean indicating whether this request was made using a secure channel, such as HTTPS.abstract booleanisUserInRole(java.lang.String role)Returntrueif the currently authenticated user is included in the specified role.abstract voidlog(java.lang.String message)Log the specified message to the application object.abstract voidlog(java.lang.String message, java.lang.Throwable exception)Log the specified message and exception to the application object.abstract voidredirect(java.lang.String url)Redirect a request to the specified URL, and cause theresponseComplete()method to be called on theFacesContextinstance for the current request.voidresponseFlushBuffer()Flushes the buffered response content to the client.voidresponseReset()Resets the current response.voidresponseSendError(int statusCode, java.lang.String message)Sends an HTTP status code with message.voidsetClientWindow(ClientWindow window)Associate this instance with aClientWindow.voidsetRequest(java.lang.Object request)Set the environment-specific request to be returned by subsequent calls togetRequest().voidsetRequestCharacterEncoding(java.lang.String encoding)Overrides the name of the character encoding used in the body of this request.voidsetResponse(java.lang.Object response)Set the environment-specific response to be returned by subsequent calls togetResponse().voidsetResponseBufferSize(int size)Set the buffer size for the current response.voidsetResponseCharacterEncoding(java.lang.String encoding)Sets the character encoding (MIME charset) of the response being sent to the client, for example, to UTF-8.voidsetResponseContentLength(int length)Set the content length of the response.voidsetResponseContentType(java.lang.String contentType)Sets the content type of the response being sent to the client, if the response has not been committed yet.voidsetResponseHeader(java.lang.String name, java.lang.String value)Set the response header with the given name and value.voidsetResponseStatus(int statusCode)Sets the HTTP status code for the response.voidsetSessionMaxInactiveInterval(int interval)Specifies the time, in seconds, between client requests before the servlet container will invalidate this session.
-
-
-
Field Detail
-
BASIC_AUTH
public static final java.lang.String BASIC_AUTH
String identifier for BASIC authentication.
- See Also:
- Constant Field Values
-
CLIENT_CERT_AUTH
public static final java.lang.String CLIENT_CERT_AUTH
String identifier for CLIENT_CERT authentication.
- See Also:
- Constant Field Values
-
DIGEST_AUTH
public static final java.lang.String DIGEST_AUTH
String identifier for DIGEST authentication.
- See Also:
- Constant Field Values
-
FORM_AUTH
public static final java.lang.String FORM_AUTH
String identifier for FORM authentication.
- See Also:
- Constant Field Values
-
-
Method Detail
-
addResponseCookie
public void addResponseCookie(java.lang.String name, java.lang.String value, java.util.Map<java.lang.String,java.lang.Object> properties)Adds the cookie represented by the arguments to the response.
Servlet: This must be accomplished by calling the
javax.servlet.http.HttpServletResponsemethodaddCookie(). TheCookieargument must be constructed by passing thenameandvalueparameters. If thepropertiesarugument is non-nulland not empty, theCookieinstance must be initialized as described below.Key in "values" MapExpected type of value. Name of setter method on Cookieinstance to be set with the value from theMap.comment String setComment domain String setDomain maxAge Integer setMaxAge secure Boolean setSecure path String setPath httpOnly Boolean setHttpOnly The default implementation throws
UnsupportedOperationExceptionand is provided for the sole purpose of not breaking existing applications that extend this class.- Parameters:
name- To be passed as the first argument to theCookieconstructor.value- To be passed as the second argument to theCookieconstructor.properties- AMapcontaing key/value pairs to be passed as arguments to the setter methods as described above.- Throws:
java.lang.IllegalArgumentException- if theproperties Mapis not-nulland not empty and contains any keys that are not one of the keys listed above.- Since:
- 2.0
-
dispatch
public abstract void dispatch(java.lang.String path) throws java.io.IOExceptionDispatch a request to the specified resource to create output for this response.
Servlet: This must be accomplished by calling the
javax.servlet.ServletContextmethodgetRequestDispatcher(path), and calling theforward()method on the resulting object.If the call to
getRequestDisatcher(path)returnsnull, send aServletResponse SC_NOT_FOUNDerror code.- Parameters:
path- Context relative path to the specified resource, which must start with a slash ("/") character- Throws:
FacesException- thrown if aServletExceptionoccursjava.io.IOException- if an input/output error occurs
-
encodeActionURL
public abstract java.lang.String encodeActionURL(java.lang.String url)
Return the input URL, after performing any rewriting needed to ensure that it will correctly identify an addressable action in the current application.
Encoding the
ClientWindowCall
ClientWindow.isClientWindowRenderModeEnabled(javax.faces.context.FacesContext). If the result isfalsetake no further action and return the rewritten URL. If the result istrue, callgetClientWindow(). If the result is non-null, callClientWindow.getId()and append the id to the query string of the URL, making the necessary allowances for a pre-existing query string or no query-string.Call
ClientWindow.getQueryURLParameters(javax.faces.context.FacesContext). If the result is non-null, for each parameter in the map, unconditionally add that parameter to the URL.The name of the query string parameter is given by the value of the constant
ResponseStateManager.CLIENT_WINDOW_URL_PARAM.Servlet: This must be the value returned by the
javax.servlet.http.HttpServletResponsemethodencodeURL(url).- Parameters:
url- The input URL to be encoded- Throws:
java.lang.NullPointerException- ifurlisnull
-
encodeNamespace
public abstract java.lang.String encodeNamespace(java.lang.String name)
Return the specified name, after prefixing it with a namespace that ensures that it will be unique within the context of a particular page.
Servlet: The input value must be returned unchanged.
- Parameters:
name- Name to be encoded
-
encodeResourceURL
public abstract java.lang.String encodeResourceURL(java.lang.String url)
Return the input URL, after performing any rewriting needed to ensure that it will correctly identify an addressable resource in the current application.
Servlet: This must be the value returned by the
javax.servlet.http.HttpServletResponsemethodencodeURL(url).- Parameters:
url- The input URL to be encoded- Throws:
java.lang.NullPointerException- ifurlisnull
-
getApplicationMap
public abstract java.util.Map<java.lang.String,java.lang.Object> getApplicationMap()
Return a mutable
Maprepresenting the application scope attributes for the current application. The returnedMapmust implement the entire contract for a modifiable map as described in the JavaDocs forjava.util.Map. Modifications made in theMapmust cause the corresponding changes in the set of application scope attributes. Particularly theclear(),remove(),put(),putAll(), andget()operations must take the appropriate action on the underlying data structure.For any of the
Mapmethods that cause an element to be removed from the underlying data structure, the following action regarding managed-beans must be taken. If the element to be removed is a managed-bean, and it has one or more public no-argument void return methods annotated withjavax.annotation.PreDestroy, each such method must be called before the element is removed from the underlying data structure. Elements that are not managed-beans, but do happen to have methods with that annotation must not have those methods called on removal. Any exception thrown by thePreDestroyannotated methods must by caught and not rethrown. The exception may be logged.It is valid to call this method during application startup or shutdown. If called at startup or shutdown time, this method returns a
Mapthat is backed by the same container context instance (ServletContextorPortletContext) as the one returned by callinggetApplicationMap()on theExternalContextreturned by theFacesContextduring an actual request.Servlet: This must be the set of attributes available via the
javax.servlet.ServletContextmethodsgetAttribute(),getAttributeNames(),removeAttribute(), andsetAttribute().
-
getAuthType
public abstract java.lang.String getAuthType()
Return the name of the authentication scheme used to authenticate the current user, if any; otherwise, return
null. For standard authentication schemes, the returned value will match one of the following constants:BASIC_AUTH,CLIENT_CERT_AUTH,DIGEST_AUTH, orFORM_AUTH.Servlet: This must be the value returned by the
javax.servlet.http.HttpServletRequestmethodgetAuthType().
-
getFlash
public Flash getFlash()
Return the threadsafe
Flashfor this application. The default implementation will throwUnsupportedOperationException. Compliant JSF runtimes must provide an implementation of this method.- Since:
- 2.0
-
getMimeType
public java.lang.String getMimeType(java.lang.String file)
Returns the MIME type of the specified file or
nullif the MIME type is not known. The MIME type is determined by the container.It is valid to call this method during application startup or shutdown. If called during application startup or shutdown, this method calls through to the
getMimeType()method on the same container context instance (ServletContextorPortletContext) as the one used when callinggetMimeType()on theExternalContextreturned by theFacesContextduring an actual request.Servlet: This must be the value returned by the
javax.servlet.ServletContextmethodgetMimeType().- Parameters:
file- The file for which the mime type should be obtained.- Since:
- 2.0
-
getContext
public abstract java.lang.Object getContext()
Return the application environment object instance for the current appication.
It is valid to call this method during application startup or shutdown. If called during application startup or shutdown, this returns the same container context instance (
ServletContextorPortletContext) as the one returned when callinggetContext()on theExternalContextreturned by theFacesContextduring an actual request.Servlet: This must be the current application's
javax.servlet.ServletContextinstance.
-
getContextName
public java.lang.String getContextName()
Return the name of the container context for this application.
Return the result of calling
getServletContextName()on theServletContextinstance for this application. It is valid to call this method during application startup or shutdown.The default implementation throws
UnsupportedOperationExceptionand is provided for the sole purpose of not breaking existing applications that extend this class.
-
getApplicationContextPath
public java.lang.String getApplicationContextPath()
Return the name of the container context for this application.
Servlet: Return the result of calling
getContextPath()on theServletContextinstance for this application.It is valid to call this method during application startup or shutdown.
The default implementation throws
UnsupportedOperationExceptionand is provided for the sole purpose of not breaking existing applications that extend this class.- Since:
- 2.2
-
getInitParameter
public abstract java.lang.String getInitParameter(java.lang.String name)
Return the value of the specified application initialization parameter (if any).
Servlet: This must be the result of the
javax.servlet.ServletContextmethodgetInitParameter(name).It is valid to call this method during application startup or shutdown. If called during application startup or shutdown, this method calls through to the actual container context to return the init parameter value.
- Parameters:
name- Name of the requested initialization parameter- Throws:
java.lang.NullPointerException- ifnameisnull
-
getInitParameterMap
public abstract java.util.Map getInitParameterMap()
Return an immutable
Mapwhose keys are the set of application initialization parameter names configured for this application, and whose values are the corresponding parameter values. The returnedMapmust implement the entire contract for an unmodifiable map as described in the JavaDocs forjava.util.Map.It is valid to call this method during application startup or shutdown. If called during application startup or shutdown, this method returns a
Mapthat is backed by the same container context instance (ServletContextorPortletContext) as the one returned by callinggetInitParameterMap()on theExternalContextreturned by theFacesContextduring an actual request.Servlet: This result must be as if it were synthesized by calling the
javax.servlet.ServletContextmethodgetInitParameterNames, and putting each configured parameter name/value pair into the result.
-
getRemoteUser
public abstract java.lang.String getRemoteUser()
Return the login name of the user making the current request if any; otherwise, return
null.Servlet: This must be the value returned by the
javax.servlet.http.HttpServletRequestmethodgetRemoteUser().
-
getRequest
public abstract java.lang.Object getRequest()
Return the environment-specific object instance for the current request.
Servlet: This must be the current request's
javax.servlet.http.HttpServletRequestinstance.
-
setRequest
public void setRequest(java.lang.Object request)
Set the environment-specific request to be returned by subsequent calls to
getRequest(). This may be used to install a wrapper for the request.The default implementation throws
UnsupportedOperationExceptionand is provided for the sole purpose of not breaking existing applications that extend this class.- Since:
- 1.2
-
getRequestScheme
public java.lang.String getRequestScheme()
Returns the name of the scheme used to make this request, for example, http, https, or ftp.
Servlet: This must be the value returned by the
javax.servlet.ServletRequestmethodgetScheme().The default implementation throws
UnsupportedOperationExceptionand is provided for the sole purpose of not breaking existing applications that extend this class.- Since:
- 2.0
-
getRequestServerName
public java.lang.String getRequestServerName()
Returns the host name of the server to which the request was sent.
Servlet: This must be the value returned by the
javax.servlet.ServletRequestmethodgetServerName().The default implementation throws
UnsupportedOperationExceptionand is provided for the sole purpose of not breaking existing applications that extend this class.- Since:
- 2.0
-
getRequestServerPort
public int getRequestServerPort()
Returns the port number to which the request was sent.
Servlet: This must be the value returned by the
javax.servlet.ServletRequestmethodgetServerPort().The default implementation throws
UnsupportedOperationExceptionand is provided for the sole purpose of not breaking existing applications that extend this class.- Since:
- 2.0
-
setRequestCharacterEncoding
public void setRequestCharacterEncoding(java.lang.String encoding) throws java.io.UnsupportedEncodingExceptionOverrides the name of the character encoding used in the body of this request.
Calling this method after the request has been accessed will have no no effect, unless a
ReaderorStreamhas been obtained from the request, in which case anIllegalStateExceptionis thrown.Servlet: This must call through to the
javax.servlet.ServletRequestmethodsetCharacterEncoding().The default implementation throws
UnsupportedOperationExceptionand is provided for the sole purpose of not breaking existing applications that extend this class.- Throws:
java.io.UnsupportedEncodingException- if this is not a valid encoding- Since:
- 1.2
-
getRealPath
public java.lang.String getRealPath(java.lang.String path)
Returns a String containing the real path for a given virtual path.
Servlet: This must be the value returned by the
javax.servlet.ServletContextmethodgetRealPath().The default implementation throws
UnsupportedOperationExceptionand is provided for the sole purpose of not breaking existing applications that extend this class.- Parameters:
path- The context of the requested initialization parameter- Since:
- 2.0
-
getRequestContextPath
public abstract java.lang.String getRequestContextPath()
Return the portion of the request URI that identifies the web application context for this request.
Servlet: This must be the value returned by the
javax.servlet.http.HttpServletRequestmethodgetContextPath().
-
getRequestCookieMap
public abstract java.util.Map<java.lang.String,java.lang.Object> getRequestCookieMap()
Return an immutable
Mapwhose keys are the set of cookie names included in the current request, and whose values (of typejavax.servlet.http.Cookie) are the first (or only) cookie for each cookie name returned by the underlying request. The returnedMapmust implement the entire contract for an unmodifiable map as described in the JavaDocs forjava.util.Map.Servlet: This must be the value returned by the
javax.servlet.http.HttpServletRequestmethodgetCookies(), unlessnullwas returned, in which case this must be a zero-length array.
-
getRequestHeaderMap
public abstract java.util.Map<java.lang.String,java.lang.String> getRequestHeaderMap()
Return an immutable
Mapwhose keys are the set of request header names included in the current request, and whose values (of type String) are the first (or only) value for each header name returned by the underlying request. The returnedMapmust implement the entire contract for an unmodifiable map as described in the JavaDocs forjava.util.Map. In addition, key comparisons must be performed in a case insensitive manner.Servlet: This must be the set of headers available via the
javax.servlet.http.HttpServletRequestmethodsgetHeader()andgetHeaderNames().
-
getRequestHeaderValuesMap
public abstract java.util.Map<java.lang.String,java.lang.String[]> getRequestHeaderValuesMap()
Return an immutable
Mapwhose keys are the set of request header names included in the current request, and whose values (of type String[]) are all of the value for each header name returned by the underlying request. The returnedMapmust implement the entire contract for an unmodifiable map as described in the JavaDocs forjava.util.Map. In addition, key comparisons must be performed in a case insensitive manner.Servlet: This must be the set of headers available via the
javax.servlet.http.HttpServletRequestmethodsgetHeaders()andgetHeaderNames().
-
getRequestLocale
public abstract java.util.Locale getRequestLocale()
Return the preferred
Localein which the client will accept content.Servlet: This must be the value returned by the
javax.servlet.ServletRequestmethodgetLocale().
-
getRequestLocales
public abstract java.util.Iterator<java.util.Locale> getRequestLocales()
Return an
Iteratorover the preferredLocales specified in the request, in decreasing order of preference.Servlet: This must be an
Iteratorover the values returned by thejavax.servlet.ServletRequestmethodgetLocales().
-
getRequestMap
public abstract java.util.Map<java.lang.String,java.lang.Object> getRequestMap()
Return a mutable
Maprepresenting the request scope attributes for the current application. The returnedMapmust implement the entire contract for a modifiable map as described in the JavaDocs forjava.util.Map. Modifications made in theMapmust cause the corresponding changes in the set of request scope attributes. Particularly theclear(),remove(),put(),putAll(), andget()operations must take the appropriate action on the underlying data structure.For any of the
Mapmethods that cause an element to be removed from the underlying data structure, the following action regarding managed-beans must be taken. If the element to be removed is a managed-bean, and it has one or more public no-argument void return methods annotated withjavax.annotation.PreDestroy, each such method must be called before the element is removed from the underlying data structure. Elements that are not managed-beans, but do happen to have methods with that annotation must not have those methods called on removal. Any exception thrown by thePreDestroyannotated methods must by caught and not rethrown. The exception may be logged.Servlet: This must be the set of attributes available via the
javax.servlet.ServletRequestmethodsgetAttribute(),getAttributeNames(),removeAttribute(), andsetAttribute().
-
getRequestParameterMap
public abstract java.util.Map<java.lang.String,java.lang.String> getRequestParameterMap()
Return an immutable
Mapwhose keys are the set of request parameters names included in the current request, and whose values (of type String) are the first (or only) value for each parameter name returned by the underlying request. The returnedMapmust implement the entire contract for an unmodifiable map as described in the JavaDocs forjava.util.Map.Servlet: This must be the set of parameters available via the
javax.servlet.ServletRequestmethodsgetParameter()andgetParameterNames().
-
getRequestParameterNames
public abstract java.util.Iterator<java.lang.String> getRequestParameterNames()
Return an
Iteratorover the names of all request parameters included in the current request.Servlet: This must be an
Iteratorover the values returned by thejavax.servlet.ServletRequestmethodgetParameterNames().
-
getRequestParameterValuesMap
public abstract java.util.Map<java.lang.String,java.lang.String[]> getRequestParameterValuesMap()
Return an immutable
Mapwhose keys are the set of request parameters names included in the current request, and whose values (of type String[]) are all of the values for each parameter name returned by the underlying request. The returnedMapmust implement the entire contract for an unmodifiable map as described in the JavaDocs forjava.util.Map.Servlet: This must be the set of parameters available via the
javax.servlet.ServletRequestmethodsgetParameterValues()andgetParameterNames().
-
getRequestPathInfo
public abstract java.lang.String getRequestPathInfo()
Return the extra path information (if any) included in the request URI; otherwise, return
null.Servlet: This must be the value returned by the
javax.servlet.http.HttpServletRequestmethodgetPathInfo().
-
getRequestServletPath
public abstract java.lang.String getRequestServletPath()
Return the servlet path information (if any) included in the request URI; otherwise, return
null.Servlet: This must be the value returned by the
javax.servlet.http.HttpServletRequestmethodgetServletPath().
-
getRequestCharacterEncoding
public java.lang.String getRequestCharacterEncoding()
Return the character encoding currently being used to interpret this request.
Servlet: This must return the value returned by the
javax.servlet.ServletRequestmethodgetCharacterEncoding().The default implementation throws
UnsupportedOperationExceptionand is provided for the sole purpose of not breaking existing applications that extend this class.- Since:
- 1.2
-
getRequestContentType
public java.lang.String getRequestContentType()
Return the MIME Content-Type for this request. If not available, return
null.Servlet: This must return the value returned by the
javax.servlet.ServletRequestmethodgetContentType().The default implementation throws
UnsupportedOperationExceptionand is provided for the sole purpose of not breaking existing applications that extend this class.- Since:
- 1.2
-
getRequestContentLength
public int getRequestContentLength()
Return the result of calling
getContentLenth()on theServletRequestinstance for this request.The default implementation throws
UnsupportedOperationExceptionand is provided for the sole purpose of not breaking existing applications that extend this class.- Since:
- 2.0
-
getResponseCharacterEncoding
public java.lang.String getResponseCharacterEncoding()
Returns the name of the character encoding (MIME charset) used for the body sent in this response.
Servlet: This must return the value returned by the
javax.servlet.ServletResponsemethodgetCharacterEncoding().The default implementation throws
UnsupportedOperationExceptionand is provided for the sole purpose of not breaking existing applications that extend this class.- Since:
- 1.2
-
getResponseContentType
public java.lang.String getResponseContentType()
Return the MIME Content-Type for this response. If not available, return
null.Servlet: This must return the value returned by the
javax.servlet.ServletResponsemethodgetContentType().The default implementation throws
UnsupportedOperationExceptionand is provided for the sole purpose of not breaking existing applications that extend this class.- Since:
- 1.2
-
getResource
public abstract java.net.URL getResource(java.lang.String path) throws java.net.MalformedURLExceptionReturn a
URLfor the application resource mapped to the specified path, if it exists; otherwise, returnnull.It is valid to call this method during application startup or shutdown. If called during application startup or shutdown, this method calls through to the
getResource()method on the same container context instance (ServletContextorPortletContext) as the one used when callinggetResource()on theExternalContextreturned by theFacesContextduring an actual request.Servlet: This must be the value returned by the
javax.servlet.ServletContextmethodgetResource(path).- Parameters:
path- The path to the requested resource, which must start with a slash ("/" character- Throws:
java.net.MalformedURLException- if the specified path is not in the correct formjava.lang.NullPointerException- ifpathisnull
-
getResourceAsStream
public abstract java.io.InputStream getResourceAsStream(java.lang.String path)
Return an
InputStreamfor an application resource mapped to the specified path, if it exists; otherwise, returnnull.It is valid to call this method during application startup or shutdown. If called during application startup or shutdown, this method calls through to the
getResourceAsStream()method on the same container context instance (ServletContextorPortletContext) as the one used when callinggetResourceAsStream()on theExternalContextreturned by theFacesContextduring an actual request.Servlet: This must be the value returned by the
javax.servlet.ServletContextmethodgetResourceAsStream(path).- Parameters:
path- The path to the requested resource, which must start with a slash ("/" character- Throws:
java.lang.NullPointerException- ifpathisnull
-
getResourcePaths
public abstract java.util.Set<java.lang.String> getResourcePaths(java.lang.String path)
Return the
Setof resource paths for all application resources whose resource path starts with the specified argument.It is valid to call this method during application startup or shutdown. If called during application startup or shutdown, this method calls through to the
getResourcePaths()method on the same container context instance (ServletContextorPortletContext) as the one used when callinggetResourcePaths()on theExternalContextreturned by theFacesContextduring an actual request.Servlet: This must be the value returned by the
javax.servlet.ServletContextmethodgetResourcePaths(path).- Parameters:
path- Partial path used to match resources, which must start with a slash ("/") character- Throws:
java.lang.NullPointerException- ifpathisnull
-
getResponse
public abstract java.lang.Object getResponse()
Return the environment-specific object instance for the current response.
Servlet: This is the current request's
javax.servlet.http.HttpServletResponseinstance.
-
setResponse
public void setResponse(java.lang.Object response)
Set the environment-specific response to be returned by subsequent calls to
getResponse(). This may be used to install a wrapper for the response.The default implementation throws
UnsupportedOperationExceptionand is provided for the sole purpose of not breaking existing applications that extend this class.- Since:
- 1.2
-
getResponseOutputStream
public java.io.OutputStream getResponseOutputStream() throws java.io.IOExceptionReturns an
OutputStreamsuitable for writing binary data to the user-agent.Servlet: This must return the value returned by the
javax.servlet.ServletResponsemethodgetOutputStream().The default implementation throws
UnsupportedOperationExceptionand is provided for the sole purpose of not breaking existing applications that extend this class.- Throws:
java.io.IOException- Since:
- 2.0
-
getResponseOutputWriter
public java.io.Writer getResponseOutputWriter() throws java.io.IOExceptionReturns a
Writersuitable for writing character data to the user-agent.Servlet: This must return the value returned by the
ServletResponse.getWriter().The default implementation throws
UnsupportedOperationExceptionand is provided for the sole purpose of not breaking existing applications that extend this class.- Throws:
java.io.IOException- Since:
- 2.0
-
setResponseCharacterEncoding
public void setResponseCharacterEncoding(java.lang.String encoding)
Sets the character encoding (MIME charset) of the response being sent to the client, for example, to UTF-8.
Servlet: This must call through to the
javax.servlet.ServletResponsemethodsetCharacterEncoding().The default implementation throws
UnsupportedOperationExceptionand is provided for the sole purpose of not breaking existing applications that extend this class.- Since:
- 1.2
-
setResponseContentType
public void setResponseContentType(java.lang.String contentType)
Sets the content type of the response being sent to the client, if the response has not been committed yet.
Servlet: This must call
setContentType()on the underlyingjavax.servlet.ServletResponseinstance.The default implementation throws
UnsupportedOperationExceptionand is provided for the sole purpose of not breaking existing applications that extend this class.- Parameters:
contentType- The content type to be set as the contentType of the response.- Since:
- 2.0
-
getSession
public abstract java.lang.Object getSession(boolean create)
If the
createparameter istrue, create (if necessary) and return a session instance associated with the current request. If thecreateparameter isfalsereturn any existing session instance associated with the current request, or returnnullif there is no such session.Servlet: This must return the result of calling
getSession(create)on the underlyingjavax.servlet.http.HttpServletRequestinstance.- Parameters:
create- Flag indicating whether or not a new session should be created if there is no session associated with the current request
-
getSessionId
public java.lang.String getSessionId(boolean create)
Return the id of the current session or the empty string if no session has been created and the
createparameter isfalse.Servlet: If
createis true, obtain a reference to theHttpSessionfor the current request (creating the session if necessary) and return its id. Ifcreateisfalse, obtain a reference to the current session, if one exists, and return its id. If no session exists, return the empty string.- Parameters:
create- Flag indicating whether or not a new session should be created if there is no session associated with the current request- Since:
- 2.2
-
getSessionMaxInactiveInterval
public int getSessionMaxInactiveInterval()
Returns the maximum time interval, in seconds, that the servlet container will keep this session open between client accesses. After this interval, the servlet container will invalidate the session. The maximum time interval can be set with the
setSessionMaxInactiveInterval(int)method.A return value of zero or less indicates that the session will never timeout.
Servlet: This must return the result of calling
getMaxInactiveIntervalon the underlyingjavax.servlet.http.HttpServletRequestinstance.The default implementation throws
UnsupportedOperationExceptionand is provided for the sole purpose of not breaking existing applications that extend this class.- Since:
- 2.1
-
getSessionMap
public abstract java.util.Map<java.lang.String,java.lang.Object> getSessionMap()
Return a mutable
Maprepresenting the session scope attributes for the current application. The returnedMapmust implement the entire contract for a modifiable map as described in the JavaDocs forjava.util.Map. Modifications made in theMapmust cause the corresponding changes in the set of session scope attributes. Particularly theclear(),remove(),put(), andget()operations must take the appropriate action on the underlying data structure. Accessing attributes via thisMapmust cause the creation of a session associated with the current request, if such a session does not already exist.For any of the
Mapmethods that cause an element to be removed from the underlying data structure, the following action regarding managed-beans must be taken. If the element to be removed is a managed-bean, and it has one or more public no-argument void return methods annotated withjavax.annotation.PreDestroy, each such method must be called before the element is removed from the underlying data structure. Elements that are not managed-beans, but do happen to have methods with that annotation must not have those methods called on removal. Any exception thrown by thePreDestroyannotated methods must by caught and not rethrown. The exception may be logged.Servlet: This must be the set of attributes available via the
javax.servlet.http.HttpSessionmethodsgetAttribute(),getAttributeNames(),removeAttribute(), andsetAttribute().
-
getUserPrincipal
public abstract java.security.Principal getUserPrincipal()
Return the
Principalobject containing the name of the current authenticated user, if any; otherwise, returnnull.Servlet: This must be the value returned by the
javax.servlet.http.HttpServletRequestmethodgetUserPrincipal().
-
getClientWindow
public ClientWindow getClientWindow()
Return the
ClientWindowset in a preceding call tosetClientWindow(javax.faces.lifecycle.ClientWindow), ornullif no such call has been made.- Since:
- 2.2
-
invalidateSession
public void invalidateSession()
Invalidates this session then unbinds any objects bound to it.
Servlet: This must be the value returned by the
javax.servlet.http.HttpSessionmethodinvalidate().The default implementation throws
UnsupportedOperationExceptionand is provided for the sole purpose of not breaking existing applications that extend this class.- Since:
- 2.0
-
isUserInRole
public abstract boolean isUserInRole(java.lang.String role)
Return
trueif the currently authenticated user is included in the specified role. Otherwise, returnfalse.Servlet: This must be the value returned by the
javax.servlet.http.HttpServletRequestmethodisUserInRole(role).- Parameters:
role- Logical role name to be checked- Throws:
java.lang.NullPointerException- ifroleisnull
-
log
public abstract void log(java.lang.String message)
Log the specified message to the application object.
It is valid to call this method during application startup or shutdown. If called during application startup or shutdown, this calls the
log()method on the same container context instance (ServletContextorPortletContext) as the one used during a call tolog()on theExternalContextreturned by theFacesContextduring an actual request.Servlet: This must be performed by calling the
javax.servlet.ServletContextmethodlog(String).- Parameters:
message- Message to be logged- Throws:
java.lang.NullPointerException- ifmessageisnull
-
log
public abstract void log(java.lang.String message, java.lang.Throwable exception)Log the specified message and exception to the application object.
It is valid to call this method during application startup or shutdown. If called during application startup or shutdown, this calls the
log()method on the same container context instance (ServletContextorPortletContext) as the one used when callinglog()on theExternalContextreturned by theFacesContextduring an actual request.Servlet: This must be performed by calling the
javax.servlet.ServletContextmethodlog(String,Throwable).- Parameters:
message- Message to be loggedexception- Exception to be logged- Throws:
java.lang.NullPointerException- ifmessageorexceptionisnull
-
redirect
public abstract void redirect(java.lang.String url) throws java.io.IOExceptionRedirect a request to the specified URL, and cause the
responseComplete()method to be called on theFacesContextinstance for the current request.The implementation must determine if the request is an
Ajaxrequest by obtaining aPartialViewContextinstance from theFacesContextand callingPartialViewContext.isAjaxRequest().Servlet: For non
Ajaxrequests, this must be accomplished by calling thejavax.servlet.http.HttpServletResponsemethodsendRedirect().For Ajax requests, the implementation must:- Get a
PartialResponseWriterinstance from theFacesContext. - Call
setResponseContentType(java.lang.String)withtext/xml - Call
setResponseCharacterEncoding(java.lang.String)withUTF-8 - Call
addResponseHeader(java.lang.String, java.lang.String)withCache-Control,no-cache - Call
PartialResponseWriter.startDocument() - Call
PartialResponseWriter.redirect(java.lang.String)with theurlargument. - Call
PartialResponseWriter.endDocument()
- Parameters:
url- Absolute URL to which the client should be redirected- Throws:
java.lang.IllegalArgumentException- if the specified url is relativejava.lang.IllegalStateException- if, in a portlet environment, the current response object is aRenderResponseinstead of anActionResponsejava.lang.IllegalStateException- if, in a servlet environment, the current response has already been committedjava.io.IOException- if an input/output error occurs
- Get a
-
setResponseHeader
public void setResponseHeader(java.lang.String name, java.lang.String value)Set the response header with the given name and value.
Servlet:This must be performed by calling the
javax.servlet.http.HttpServletResponsesetHeadermethod.The default implementation throws
UnsupportedOperationExceptionand is provided for the sole purpose of not breaking existing applications that extend this class.- Parameters:
name- The name of the response header.value- The value of the response header.- Since:
- 2.0
-
addResponseHeader
public void addResponseHeader(java.lang.String name, java.lang.String value)Add the given name and value to the response header.
Servlet:This must be performed by calling the
javax.servlet.http.HttpServletResponseaddHeadermethod.The default implementation throws
UnsupportedOperationExceptionand is provided for the sole purpose of not breaking existing applications that extend this class.- Parameters:
name- The name of the response header.value- The value of the response header.- Since:
- 2.0
-
setResponseBufferSize
public void setResponseBufferSize(int size)
Set the buffer size for the current response.
Servlet: This must be performed by calling the
javax.servlet.http.HttpServletResponsesetBufferSizemethod.The default implementation throws
UnsupportedOperationExceptionand is provided for the sole purpose of not breaking existing applications that extend this class.- Parameters:
size- the new buffer size- Since:
- 2.0
-
getResponseBufferSize
public int getResponseBufferSize()
Return the buffer size for the current response.
Servlet: This must be performed by calling the
javax.servlet.http.HttpServletResponsegetBufferSizemethod.The default implementation throws
UnsupportedOperationExceptionand is provided for the sole purpose of not breaking existing applications that extend this class.- Since:
- 2.0
-
isResponseCommitted
public boolean isResponseCommitted()
Check if the current response has been committed.
Servlet: This must be performed by calling the
javax.servlet.http.HttpServletResponseisCommittedmethod.The default implementation throws
UnsupportedOperationExceptionand is provided for the sole purpose of not breaking existing applications that extend this class.- Since:
- 2.0
-
responseReset
public void responseReset()
Resets the current response.
Servlet: This must be performed by calling the
javax.servlet.http.HttpServletResponseresetmethod.The default implementation throws
UnsupportedOperationExceptionand is provided for the sole purpose of not breaking existing applications that extend this class.- Since:
- 2.0
-
responseSendError
public void responseSendError(int statusCode, java.lang.String message) throws java.io.IOExceptionSends an HTTP status code with message.
Servlet: This must be performed by calling the
javax.servlet.http.HttpServletResponsesendErrormethod.The default implementation throws
UnsupportedOperationExceptionand is provided for the sole purpose of not breaking existing applications that extend this class.- Parameters:
statusCode- an HTTP status codemessage- an option message to detail the cause of the code- Throws:
java.io.IOException- Since:
- 2.0
-
setResponseStatus
public void setResponseStatus(int statusCode)
Sets the HTTP status code for the response.
Servlet: This must be performed by calling the
javax.servlet.http.HttpServletResponsesetStatusmethod.The default implementation throws
UnsupportedOperationExceptionand is provided for the sole purpose of not breaking existing applications that extend this class.- Parameters:
statusCode- an HTTP status code- Since:
- 2.0
-
setSessionMaxInactiveInterval
public void setSessionMaxInactiveInterval(int interval)
Specifies the time, in seconds, between client requests before the servlet container will invalidate this session.
An interval value of zero or less indicates that the session should never timeout.
Servlet: This must call
setMaxInactiveIntervalon the underlyingjavax.servlet.http.HttpServletRequestinstance.The default implementation throws
UnsupportedOperationExceptionand is provided for the sole purpose of not breaking existing applications that extend this class.- Since:
- 2.1
-
setClientWindow
public void setClientWindow(ClientWindow window)
Associate this instance with a
ClientWindow.- Parameters:
window- the window with which this instance is associated.- Since:
- 2.2
-
responseFlushBuffer
public void responseFlushBuffer() throws java.io.IOExceptionFlushes the buffered response content to the client.
Servlet: This must be performed by calling the
javax.servlet.http.HttpServletResponseflushBuffermethod.The default implementation throws
UnsupportedOperationExceptionand is provided for the sole purpose of not breaking existing applications that extend this class.- Throws:
java.io.IOException- Since:
- 2.0
-
setResponseContentLength
public void setResponseContentLength(int length)
Set the content length of the response.
Servlet: This must be performed by calling the
javax.servlet.http.HttpServletResponsesetContentLengthmethod.The default implementation throws
UnsupportedOperationExceptionand is provided for the sole purpose of not breaking existing applications that extend this class.- Since:
- 2.0
-
encodeBookmarkableURL
public java.lang.String encodeBookmarkableURL(java.lang.String baseUrl, java.util.Map<java.lang.String,java.util.List<java.lang.String>> parameters)The purpose of this method is to generate a query string from the collection of Parameter objects provided by the parameters argument and append that query string to the baseUrl. This method must be able to encode the parameters to a baseUrl that may or may not have existing query parameters. The parameter values should be encoded appropriately for the environment so that the resulting URL can be used as the target of a link (e.g., in an href attribute) in a JSF response. It's possible for an ExternalContext implementation to override this method in any way that would make the URL bookmarkable in that environment.
See
encodeActionURL(java.lang.String)for the required specification of how to encode theClientWindow.The default implementation throws
UnsupportedOperationExceptionand is provided for the sole purpose of not breaking existing applications that extend this class.- Parameters:
baseUrl- The base URL onto which the query string generated by this method will be appended. The URL may contain query parameters.parameters- The collection of Parameter objects, representing name=value pairs that are used to produce a query string- Since:
- 2.0
-
encodeRedirectURL
public java.lang.String encodeRedirectURL(java.lang.String baseUrl, java.util.Map<java.lang.String,java.util.List<java.lang.String>> parameters)The purpose of this method is to generate a query string from the collection of Parameter objects provided by the parameters argument and append that query string to the baseUrl. This method must be able to encode the parameters to a baseUrl that may or may not have existing query parameters. The parameter values should be encoded appropriately for the environment so that the resulting URL can be used as the target of a redirect. It's possible for an ExternalContext implementation to override this method to accomodate the definition of redirect for that environment.See
encodeActionURL(java.lang.String)for the required specification of how to encode theClientWindow.- Parameters:
baseUrl- The base URL onto which the query string generated by this method will be appended. The URL may contain query parameters.parameters- The collection of Parameter objects, representing name=value pairs that are used to produce a query string- Since:
- 2.0
-
encodePartialActionURL
public java.lang.String encodePartialActionURL(java.lang.String url)
Return the input URL, after performing any rewriting needed to ensure that it can be used in a partial page submission (ajax request) to correctly identify an addressable action in the current application.
See
encodeActionURL(java.lang.String)for the required specification of how to encode theClientWindow.Servlet:Returns the same encoded URL as the
encodeActionURL(String url)method.Portlet:Returns an encoded URL that, upon HTTP POST, will invoke the RESOURCE_PHASE of the portlet lifecycle.
- Parameters:
url- The input URL to be encoded- Throws:
java.lang.NullPointerException- ifurlisnull- Since:
- 2.0
-
isSecure
public boolean isSecure()
Returns a boolean indicating whether this request was made using a secure channel, such as HTTPS.
Servlet: This must return the result of calling
isSecureon the underlyingjavax.servlet.http.HttpServletRequestinstance.The default implementation throws
UnsupportedOperationExceptionand is provided for the sole purpose of not breaking existing applications that extend this class.- Since:
- 2.1
-
-