This implementation of ExternalContext
is specific to the servlet implementation.
-
Field Summary
Fields inherited from class jakarta.faces.context.ExternalContext
BASIC_AUTH, CLIENT_CERT_AUTH, DIGEST_AUTH, FORM_AUTH
-
Constructor Summary
ConstructorDescriptionExternalContextImpl
(ServletContext sc, ServletRequest request, ServletResponse response) -
Method Summary
Modifier and TypeMethodDescriptionvoid
Adds the cookie represented by the arguments to the response.void
addResponseHeader
(String name, String value) Add the given name and value to the response header.void
Dispatch a request to the specified resource to create output for this response.encodeActionURL
(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.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.encodeNamespace
(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.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.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.encodeResourceURL
(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.encodeWebsocketURL
(String url) Return the websocket URL, after performing any rewriting needed to ensure that it will correctly identify an addressable websocket in the current application.Return the name of the container context for this application.Return a mutableMap
representing the application scope attributes for the current application.Return the name of the authentication scheme used to authenticate the current user, if any; otherwise, returnnull
.Return theClientWindow
set in a preceding call toExternalContext.setClientWindow(jakarta.faces.lifecycle.ClientWindow)
, ornull
if no such call has been made.Return the application environment object instance for the current appication.Return the name of the container context for this application.getFlash()
Return the threadsafeFlash
for this application.getInitParameter
(String name) Return the value of the specified application initialization parameter (if any).Return an immutableMap
whose keys are the set of application initialization parameter names configured for this application, and whose values are the corresponding parameter values.getMimeType
(String file) Returns the MIME type of the specified file ornull
if the MIME type is not known.getRealPath
(String path) Returns a String containing the real path for a given virtual path.Return the login name of the user making the current request if any; otherwise, returnnull
.Return the environment-specific object instance for the current request.Return the character encoding currently being used to interpret this request.int
Return the result of callinggetContentLenth()
on theServletRequest
instance for this request.Return the MIME Content-Type for this request.Return the portion of the request URI that identifies the web application context for this request.Return an immutableMap
whose keys are the set of cookie names included in the current request, and whose values (of typejakarta.servlet.http.Cookie
) are the first (or only) cookie for each cookie name returned by the underlying request.Return an immutableMap
whose 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.Return an immutableMap
whose 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.Return the preferredLocale
in which the client will accept content.Return anIterator
over the preferredLocale
s specified in the request, in decreasing order of preference.Return a mutableMap
representing the request scope attributes for the current application.Return an immutableMap
whose 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.Return anIterator
over the names of all request parameters included in the current request.Return an immutableMap
whose 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.Return the extra path information (if any) included in the request URI; otherwise, returnnull
.Returns the name of the scheme used to make this request, for example, http, https, or ftp.Returns the host name of the server to which the request was sent.int
Returns the port number to which the request was sent.Return the Jakarta Servlet path information (if any) included in the request URI; otherwise, returnnull
.getResource
(String path) Return aURL
for the application resource mapped to the specified path, if it exists; otherwise, returnnull
.getResourceAsStream
(String path) Return anInputStream
for an application resource mapped to the specified path, if it exists; otherwise, returnnull
.getResourcePaths
(String path) Return theSet
of resource paths for all application resources whose resource path starts with the specified argument.Return the environment-specific object instance for the current response.int
Return the buffer size for the current response.Returns the name of the character encoding (MIME charset) used for the body sent in this response.Return the MIME Content-Type for this response.Returns anOutputStream
suitable for writing binary data to the user-agent.Returns aWriter
suitable for writing character data to the user-agent.getSession
(boolean create) If thecreate
parameter istrue
, create (if necessary) and return a session instance associated with the current request.getSessionId
(boolean create) Return the id of the current session or the empty string if no session has been created and thecreate
parameter isfalse
.Return a mutableMap
representing the session scope attributes for the current application.int
Returns the maximum time interval, in seconds, that the Jakarta Servlet container will keep this session open between client accesses.Return thePrincipal
object containing the name of the current authenticated user, if any; otherwise, returnnull
.void
Invalidates this session then unbinds any objects bound to it.boolean
Check if the current response has been committed.boolean
isSecure()
Returns a boolean indicating whether this request was made using a secure channel, such as HTTPS.boolean
isUserInRole
(String role) Returntrue
if the currently authenticated user is included in the specified role.void
Log the specified message to the application object.void
Log the specified message and exception to the application object.void
Redirect a request to the specified URL, and cause theresponseComplete()
method to be called on theFacesContext
instance for the current request.void
release()
Release any resources associated with thisExternalContext
instance.void
Flushes the buffered response content to the client.void
Resets the current response.void
responseSendError
(int statusCode, String message) Sends an HTTP status code with message.void
setClientWindow
(ClientWindow window) Associate this instance with aClientWindow
.void
setRequest
(Object request) Set the environment-specific request to be returned by subsequent calls toExternalContext.getRequest()
.void
setRequestCharacterEncoding
(String encoding) Overrides the name of the character encoding used in the body of this request.void
setResponse
(Object response) Set the environment-specific response to be returned by subsequent calls toExternalContext.getResponse()
.void
setResponseBufferSize
(int size) Set the buffer size for the current response.void
setResponseCharacterEncoding
(String encoding) Sets the character encoding (MIME charset) of the response being sent to the client, for example, to UTF-8.void
setResponseContentLength
(int length) Set the content length of the response as an intvoid
setResponseContentLengthLong
(long length) Set the content length of the response as a long.void
setResponseContentType
(String contentType) Sets the content type of the response being sent to the client, if the response has not been committed yet.void
setResponseHeader
(String name, String value) Set the response header with the given name and value.void
setResponseStatus
(int statusCode) Sets the HTTP status code for the response.void
setSessionMaxInactiveInterval
(int interval) Specifies the time, in seconds, between client requests before the Jakarta Servlet container will invalidate this session.
-
Constructor Details
-
ExternalContextImpl
-
-
Method Details
-
getSession
Description copied from class:ExternalContext
If the
create
parameter istrue
, create (if necessary) and return a session instance associated with the current request. If thecreate
parameter isfalse
return any existing session instance associated with the current request, or returnnull
if there is no such session.Jakarta Servlet: This must return the result of calling
getSession(create)
on the underlyingjakarta.servlet.http.HttpServletRequest
instance.- Specified by:
getSession
in classExternalContext
- Parameters:
create
- Flag indicating whether or not a new session should be created if there is no session associated with the current request- Returns:
- the session object of the current request.
- See Also:
-
getSessionId
Description copied from class:ExternalContext
Return the id of the current session or the empty string if no session has been created and the
create
parameter isfalse
.Jakarta Servlet: If
create
is true, obtain a reference to theHttpSession
for the current request (creating the session if necessary) and return its id. Ifcreate
isfalse
, obtain a reference to the current session, if one exists, and return its id. If no session exists, return the empty string.- Overrides:
getSessionId
in classExternalContext
- Parameters:
create
- Flag indicating whether or not a new session should be created if there is no session associated with the current request- Returns:
- the session id for the current request.
-
getContext
Description copied from class:ExternalContext
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 (
ServletContext
orPortletContext
) as the one returned when callinggetContext()
on theExternalContext
returned by theFacesContext
during an actual request.Jakarta Servlet: This must be the current application's
jakarta.servlet.ServletContext
instance.- Specified by:
getContext
in classExternalContext
- Returns:
- the object of the
ServletContext
. - See Also:
-
getContextName
Description copied from class:ExternalContext
Return the name of the container context for this application.
Return the result of calling
getServletContextName()
on theServletContext
instance for this application. It is valid to call this method during application startup or shutdown.The default implementation throws
UnsupportedOperationException
and is provided for the sole purpose of not breaking existing applications that extend this class.- Overrides:
getContextName
in classExternalContext
- Returns:
- the name the
ServletContext
. - See Also:
-
getRequest
Description copied from class:ExternalContext
Return the environment-specific object instance for the current request.
Jakarta Servlet: This must be the current request's
jakarta.servlet.http.HttpServletRequest
instance.- Specified by:
getRequest
in classExternalContext
- Returns:
- the instance of the current request.
- See Also:
-
setRequest
Description copied from class:ExternalContext
Set the environment-specific request to be returned by subsequent calls to
ExternalContext.getRequest()
. This may be used to install a wrapper for the request.The default implementation throws
UnsupportedOperationException
and is provided for the sole purpose of not breaking existing applications that extend this class.- Overrides:
setRequest
in classExternalContext
- Parameters:
request
- the request object to be set.- See Also:
-
setRequestCharacterEncoding
Description copied from class:ExternalContext
Overrides 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
Reader
orStream
has been obtained from the request, in which case anIllegalStateException
is thrown.Jakarta Servlet: This must call through to the
jakarta.servlet.ServletRequest
methodsetCharacterEncoding()
.The default implementation throws
UnsupportedOperationException
and is provided for the sole purpose of not breaking existing applications that extend this class.- Overrides:
setRequestCharacterEncoding
in classExternalContext
- Parameters:
encoding
- the encoding name to be set.- Throws:
UnsupportedEncodingException
- if this is not a valid encoding- See Also:
-
getResponse
Description copied from class:ExternalContext
Return the environment-specific object instance for the current response.
Jakarta Servlet: This is the current request's
jakarta.servlet.http.HttpServletResponse
instance.- Specified by:
getResponse
in classExternalContext
- Returns:
- the instance of the current
jakarta.servlet.http.HttpServletResponse
. - See Also:
-
setResponse
Description copied from class:ExternalContext
Set the environment-specific response to be returned by subsequent calls to
ExternalContext.getResponse()
. This may be used to install a wrapper for the response.The default implementation throws
UnsupportedOperationException
and is provided for the sole purpose of not breaking existing applications that extend this class.- Overrides:
setResponse
in classExternalContext
- Parameters:
response
- the response instance to be set.- See Also:
-
getClientWindow
Description copied from class:ExternalContext
Return the
ClientWindow
set in a preceding call toExternalContext.setClientWindow(jakarta.faces.lifecycle.ClientWindow)
, ornull
if no such call has been made.- Overrides:
getClientWindow
in classExternalContext
- Returns:
- the instance of the
ClientWindow
.
-
setClientWindow
Description copied from class:ExternalContext
Associate this instance with a
ClientWindow
.- Overrides:
setClientWindow
in classExternalContext
- Parameters:
window
- the window with which this instance is associated.
-
setResponseCharacterEncoding
Description copied from class:ExternalContext
Sets the character encoding (MIME charset) of the response being sent to the client, for example, to UTF-8.
Jakarta Servlet: This must call through to the
jakarta.servlet.ServletResponse
methodsetCharacterEncoding()
.The default implementation throws
UnsupportedOperationException
and is provided for the sole purpose of not breaking existing applications that extend this class.- Overrides:
setResponseCharacterEncoding
in classExternalContext
- Parameters:
encoding
- the character encoding to be sent by the current response.- See Also:
-
getApplicationMap
Description copied from class:ExternalContext
Return a mutable
Map
representing the application scope attributes for the current application. The returnedMap
must implement the entire contract for a modifiable map as described in the JavaDocs forjava.util.Map
. Modifications made in theMap
must 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.It is valid to call this method during application startup or shutdown. If called at startup or shutdown time, this method returns a
Map
that is backed by the same container context instance (ServletContext
orPortletContext
) as the one returned by callinggetApplicationMap()
on theExternalContext
returned by theFacesContext
during an actual request.Jakarta Servlet: This must be the set of attributes available via the
jakarta.servlet.ServletContext
methodsgetAttribute()
,getAttributeNames()
,removeAttribute()
, andsetAttribute()
.- Specified by:
getApplicationMap
in classExternalContext
- Returns:
- the map associated with the backed
ServletContext
. - See Also:
-
getApplicationContextPath
Description copied from class:ExternalContext
Return the name of the container context for this application.
Jakarta Servlet: Return the result of calling
getContextPath()
on theServletContext
instance for this application.It is valid to call this method during application startup or shutdown.
The default implementation throws
UnsupportedOperationException
and is provided for the sole purpose of not breaking existing applications that extend this class.- Overrides:
getApplicationContextPath
in classExternalContext
- Returns:
- the context path of this application.
-
getSessionMap
Description copied from class:ExternalContext
Return a mutable
Map
representing the session scope attributes for the current application. The returnedMap
must implement the entire contract for a modifiable map as described in the JavaDocs forjava.util.Map
. Modifications made in theMap
must 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 thisMap
must cause the creation of a session associated with the current request, if such a session does not already exist.Jakarta Servlet: This must be the set of attributes available via the
jakarta.servlet.http.HttpSession
methodsgetAttribute()
,getAttributeNames()
,removeAttribute()
, andsetAttribute()
.- Specified by:
getSessionMap
in classExternalContext
- Returns:
- the session map for the current application.
- See Also:
-
getRequestMap
Description copied from class:ExternalContext
Return a mutable
Map
representing the request scope attributes for the current application. The returnedMap
must implement the entire contract for a modifiable map as described in the JavaDocs forjava.util.Map
. Modifications made in theMap
must 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.Jakarta Servlet: This must be the set of attributes available via the
jakarta.servlet.ServletRequest
methodsgetAttribute()
,getAttributeNames()
,removeAttribute()
, andsetAttribute()
.- Specified by:
getRequestMap
in classExternalContext
- Returns:
- the map including the attributes of the current request.
- See Also:
-
getRequestHeaderMap
Description copied from class:ExternalContext
Return an immutable
Map
whose 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 returnedMap
must 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.Jakarta Servlet: This must be the set of headers available via the
jakarta.servlet.http.HttpServletRequest
methodsgetHeader()
andgetHeaderNames()
.- Specified by:
getRequestHeaderMap
in classExternalContext
- Returns:
- the header map in the current request.
- See Also:
-
getRequestHeaderValuesMap
Description copied from class:ExternalContext
Return an immutable
Map
whose 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 returnedMap
must 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.Jakarta Servlet: This must be the set of headers available via the
jakarta.servlet.http.HttpServletRequest
methodsgetHeaders()
andgetHeaderNames()
.- Specified by:
getRequestHeaderValuesMap
in classExternalContext
- Returns:
- the header values map in the current request.
- See Also:
-
getRequestCookieMap
Description copied from class:ExternalContext
Return an immutable
Map
whose keys are the set of cookie names included in the current request, and whose values (of typejakarta.servlet.http.Cookie
) are the first (or only) cookie for each cookie name returned by the underlying request. The returnedMap
must implement the entire contract for an unmodifiable map as described in the JavaDocs forjava.util.Map
.Jakarta Servlet: This must be the value returned by the
jakarta.servlet.http.HttpServletRequest
methodgetCookies()
, unlessnull
was returned, in which case this must be a zero-length array.- Specified by:
getRequestCookieMap
in classExternalContext
- Returns:
- the cookie map in the current request.
- See Also:
-
getInitParameterMap
Description copied from class:ExternalContext
Return an immutable
Map
whose keys are the set of application initialization parameter names configured for this application, and whose values are the corresponding parameter values. The returnedMap
must 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
Map
that is backed by the same container context instance (ServletContext
orPortletContext
) as the one returned by callinggetInitParameterMap()
on theExternalContext
returned by theFacesContext
during an actual request.Jakarta Servlet: This result must be as if it were synthesized by calling the
jakarta.servlet.ServletContext
methodgetInitParameterNames
, and putting each configured parameter name/value pair into the result.- Specified by:
getInitParameterMap
in classExternalContext
- Returns:
- the init parameter map for this application.
- See Also:
-
getRequestParameterMap
Description copied from class:ExternalContext
Return an immutable
Map
whose 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 returnedMap
must implement the entire contract for an unmodifiable map as described in the JavaDocs forjava.util.Map
.Jakarta Servlet: This must be the set of parameters available via the
jakarta.servlet.ServletRequest
methodsgetParameter()
andgetParameterNames()
.- Specified by:
getRequestParameterMap
in classExternalContext
- Returns:
- the map for the current request parameters.
- See Also:
-
getRequestParameterValuesMap
Description copied from class:ExternalContext
Return an immutable
Map
whose 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 returnedMap
must implement the entire contract for an unmodifiable map as described in the JavaDocs forjava.util.Map
.Jakarta Servlet: This must be the set of parameters available via the
jakarta.servlet.ServletRequest
methodsgetParameterValues()
andgetParameterNames()
.- Specified by:
getRequestParameterValuesMap
in classExternalContext
- Returns:
- the map for the parameter values of the current request.
- See Also:
-
getRequestParameterNames
Description copied from class:ExternalContext
Return an
Iterator
over the names of all request parameters included in the current request.Jakarta Servlet: This must be an
Iterator
over the values returned by thejakarta.servlet.ServletRequest
methodgetParameterNames()
.- Specified by:
getRequestParameterNames
in classExternalContext
- Returns:
- the
Iterator
for the names of the current request parameters. - See Also:
-
getRequestLocale
Description copied from class:ExternalContext
Return the preferred
Locale
in which the client will accept content.Jakarta Servlet: This must be the value returned by the
jakarta.servlet.ServletRequest
methodgetLocale()
.- Specified by:
getRequestLocale
in classExternalContext
- Returns:
- the
Locale
of the current request. - See Also:
-
getRequestLocales
Description copied from class:ExternalContext
Return an
Iterator
over the preferredLocale
s specified in the request, in decreasing order of preference.Jakarta Servlet: This must be an
Iterator
over the values returned by thejakarta.servlet.ServletRequest
methodgetLocales()
.- Specified by:
getRequestLocales
in classExternalContext
- Returns:
- the
Iterator
ofLocale
s of the current request. - See Also:
-
getRequestPathInfo
Description copied from class:ExternalContext
Return the extra path information (if any) included in the request URI; otherwise, return
null
.Jakarta Servlet: This must be the value returned by the
jakarta.servlet.http.HttpServletRequest
methodgetPathInfo()
.- Specified by:
getRequestPathInfo
in classExternalContext
- Returns:
- the path information of the current request.
- See Also:
-
getRealPath
Description copied from class:ExternalContext
Returns a String containing the real path for a given virtual path.
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
getRealPath()
method on the same container context instance (ServletContext
orPortletContext
) as the one used when callinggetRealPath()
on theExternalContext
returned by theFacesContext
during an actual request.Jakarta Servlet: This must be the value returned by the
jakarta.servlet.ServletContext
methodgetRealPath()
.The default implementation throws
UnsupportedOperationException
and is provided for the sole purpose of not breaking existing applications that extend this class.- Overrides:
getRealPath
in classExternalContext
- Parameters:
path
- The context of the requested initialization parameter- Returns:
- the real path for the specified virtual path.
- See Also:
-
getRequestContextPath
Description copied from class:ExternalContext
Return the portion of the request URI that identifies the web application context for this request.
Jakarta Servlet: This must be the value returned by the
jakarta.servlet.http.HttpServletRequest
methodgetContextPath()
.- Specified by:
getRequestContextPath
in classExternalContext
- Returns:
- the context path for this request.
- See Also:
-
getRequestServletPath
Description copied from class:ExternalContext
Return the Jakarta Servlet path information (if any) included in the request URI; otherwise, return
null
.Jakarta Servlet: This must be the value returned by the
jakarta.servlet.http.HttpServletRequest
methodgetServletPath()
.- Specified by:
getRequestServletPath
in classExternalContext
- Returns:
- the Jakarta Servlet path information of the current request.
- See Also:
-
getRequestCharacterEncoding
Description copied from class:ExternalContext
Return the character encoding currently being used to interpret this request.
Jakarta Servlet: This must return the value returned by the
jakarta.servlet.ServletRequest
methodgetCharacterEncoding()
.The default implementation throws
UnsupportedOperationException
and is provided for the sole purpose of not breaking existing applications that extend this class.- Overrides:
getRequestCharacterEncoding
in classExternalContext
- Returns:
- the character encoding currently being used.
- See Also:
-
getRequestContentType
Description copied from class:ExternalContext
Return the MIME Content-Type for this request. If not available, return
null
.Jakarta Servlet: This must return the value returned by the
jakarta.servlet.ServletRequest
methodgetContentType()
.The default implementation throws
UnsupportedOperationException
and is provided for the sole purpose of not breaking existing applications that extend this class.- Overrides:
getRequestContentType
in classExternalContext
- Returns:
- the Content-Type for this request.
- See Also:
-
getRequestContentLength
public int getRequestContentLength()Description copied from class:ExternalContext
Return the result of calling
getContentLenth()
on theServletRequest
instance for this request.The default implementation throws
UnsupportedOperationException
and is provided for the sole purpose of not breaking existing applications that extend this class.- Overrides:
getRequestContentLength
in classExternalContext
- Returns:
- the content length of the current request.
- See Also:
-
getResponseCharacterEncoding
Description copied from class:ExternalContext
Returns the name of the character encoding (MIME charset) used for the body sent in this response.
Jakarta Servlet: This must return the value returned by the
jakarta.servlet.ServletResponse
methodgetCharacterEncoding()
.Portlet: if this method is called during a lifecycle phase other than RENDER_RESPONSE, this must return
null
. If called during RENDER_RESPONSE, return the response encoding of the portlet response.The default implementation throws
UnsupportedOperationException
and is provided for the sole purpose of not breaking existing applications that extend this class.- Overrides:
getResponseCharacterEncoding
in classExternalContext
- Returns:
- the name of the character encoding.
- See Also:
-
getResponseContentType
Description copied from class:ExternalContext
Return the MIME Content-Type for this response. If not available, return
null
.Jakarta Servlet: This must return the value returned by the
jakarta.servlet.ServletResponse
methodgetContentType()
.The default implementation throws
UnsupportedOperationException
and is provided for the sole purpose of not breaking existing applications that extend this class.- Overrides:
getResponseContentType
in classExternalContext
- Returns:
- the MIME Content-Type for this response.
- See Also:
-
getInitParameter
Description copied from class:ExternalContext
Return the value of the specified application initialization parameter (if any).
Jakarta Servlet: This must be the result of the
jakarta.servlet.ServletContext
methodgetInitParameter(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.
- Specified by:
getInitParameter
in classExternalContext
- Parameters:
name
- Name of the requested initialization parameter- Returns:
- the value of the specified parameter.
- See Also:
-
getResourcePaths
Description copied from class:ExternalContext
Return the
Set
of 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 (ServletContext
orPortletContext
) as the one used when callinggetResourcePaths()
on theExternalContext
returned by theFacesContext
during an actual request.Jakarta Servlet: This must be the value returned by the
jakarta.servlet.ServletContext
methodgetResourcePaths(path).
- Specified by:
getResourcePaths
in classExternalContext
- Parameters:
path
- Partial path used to match resources, which must start with a slash ("/") character- Returns:
- the
Set
of resource paths for the application resources. - See Also:
-
getResourceAsStream
Description copied from class:ExternalContext
Return an
InputStream
for 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 (ServletContext
orPortletContext
) as the one used when callinggetResourceAsStream()
on theExternalContext
returned by theFacesContext
during an actual request.Jakarta Servlet: This must be the value returned by the
jakarta.servlet.ServletContext
methodgetResourceAsStream(path)
.- Specified by:
getResourceAsStream
in classExternalContext
- Parameters:
path
- The path to the requested resource, which must start with a slash ("/" character- Returns:
- the
InputStream
for the application resource. - See Also:
-
getResource
Description copied from class:ExternalContext
Return a
URL
for 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 (ServletContext
orPortletContext
) as the one used when callinggetResource()
on theExternalContext
returned by theFacesContext
during an actual request.Jakarta Servlet: This must be the value returned by the
jakarta.servlet.ServletContext
methodgetResource(path)
.- Specified by:
getResource
in classExternalContext
- Parameters:
path
- The path to the requested resource, which must start with a slash ("/" character- Returns:
- the URL of the resource.
- See Also:
-
encodeActionURL
Description copied from class:ExternalContext
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
ClientWindow
Call
ClientWindow.isClientWindowRenderModeEnabled(jakarta.faces.context.FacesContext)
. If the result isfalse
take no further action and return the rewritten URL. If the result istrue
, callExternalContext.getClientWindow()
. 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(jakarta.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
.Jakarta Servlet: This must be the value returned by the
jakarta.servlet.http.HttpServletResponse
methodencodeURL(url)
.- Specified by:
encodeActionURL
in classExternalContext
- Parameters:
url
- The input URL to be encoded- Returns:
- the encoded URL.
- See Also:
-
encodeResourceURL
Description copied from class:ExternalContext
Return the input URL, after performing any rewriting needed to ensure that it will correctly identify an addressable resource in the current application.
Jakarta Servlet: This must be the value returned by the
jakarta.servlet.http.HttpServletResponse
methodencodeURL(url)
.- Specified by:
encodeResourceURL
in classExternalContext
- Parameters:
url
- The input URL to be encoded- Returns:
- the encoded resource URL.
- See Also:
-
encodeWebsocketURL
Description copied from class:ExternalContext
Return the websocket URL, after performing any rewriting needed to ensure that it will correctly identify an addressable websocket in the current application.
Jakarta Servlet: This must ensure that the input URL is prefixed with the correct websocket scheme, domain and port and then encoded by
ExternalContext.encodeResourceURL(String)
.- Specified by:
encodeWebsocketURL
in classExternalContext
- Parameters:
url
- The input URL to be encoded.- Returns:
- the encoded websocket URL.
- See Also:
-
encodeNamespace
Description copied from class:ExternalContext
Return the specified name, after prefixing it with a namespace that ensures that it will be unique within the context of a particular page.
Jakarta Servlet: The input value must be returned unchanged.
- Specified by:
encodeNamespace
in classExternalContext
- Parameters:
name
- Name to be encoded- Returns:
- the unique name prefixed with namespace.
- See Also:
-
dispatch
Description copied from class:ExternalContext
Dispatch a request to the specified resource to create output for this response.
Jakarta Servlet: This must be accomplished by calling the
jakarta.servlet.ServletContext
methodgetRequestDispatcher(path)
, and calling theforward()
method on the resulting object.If the call to
getRequestDisatcher(path)
returnsnull
, send aServletResponse SC_NOT_FOUND
error code.- Specified by:
dispatch
in classExternalContext
- Parameters:
requestURI
- Context relative path to the specified resource, which must start with a slash ("/") character- Throws:
IOException
- if an input/output error occursFacesException
- thrown if aServletException
occurs- See Also:
-
redirect
Description copied from class:ExternalContext
Redirect a request to the specified URL, and cause the
responseComplete()
method to be called on theFacesContext
instance for the current request.The implementation must determine if the request is an
Ajax
request by obtaining aPartialViewContext
instance from theFacesContext
and callingPartialViewContext.isAjaxRequest()
.Jakarta Servlet: For non
Ajax
requests, this must be accomplished by calling thejakarta.servlet.http.HttpServletResponse
methodsendRedirect()
.For Ajax requests, the implementation must:- Get a
PartialResponseWriter
instance from theFacesContext
. - Call
ExternalContext.setResponseContentType(java.lang.String)
withtext/xml
- Call
ExternalContext.setResponseCharacterEncoding(java.lang.String)
withUTF-8
- Call
ExternalContext.addResponseHeader(java.lang.String, java.lang.String)
withCache-Control
,no-cache
- Call
PartialResponseWriter.startDocument()
- Call
PartialResponseWriter.redirect(java.lang.String)
with theurl
argument. - Call
PartialResponseWriter.endDocument()
- Specified by:
redirect
in classExternalContext
- Parameters:
requestURI
- Absolute URL to which the client should be redirected- Throws:
IOException
- if an input/output error occurs- See Also:
- Get a
-
log
Description copied from class:ExternalContext
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 (ServletContext
orPortletContext
) as the one used during a call tolog()
on theExternalContext
returned by theFacesContext
during an actual request.Jakarta Servlet: This must be performed by calling the
jakarta.servlet.ServletContext
methodlog(String)
.- Specified by:
log
in classExternalContext
- Parameters:
message
- Message to be logged- See Also:
-
log
Description copied from class:ExternalContext
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 (ServletContext
orPortletContext
) as the one used when callinglog()
on theExternalContext
returned by theFacesContext
during an actual request.Jakarta Servlet: This must be performed by calling the
jakarta.servlet.ServletContext
methodlog(String,Throwable)
.- Specified by:
log
in classExternalContext
- Parameters:
message
- Message to be loggedthrowable
- Exception to be logged- See Also:
-
getAuthType
Description copied from class:ExternalContext
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
.Jakarta Servlet: This must be the value returned by the
jakarta.servlet.http.HttpServletRequest
methodgetAuthType()
.- Specified by:
getAuthType
in classExternalContext
- Returns:
- the authentication type.
- See Also:
-
getMimeType
Description copied from class:ExternalContext
Returns the MIME type of the specified file or
null
if 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 (ServletContext
orPortletContext
) as the one used when callinggetMimeType()
on theExternalContext
returned by theFacesContext
during an actual request.Jakarta Servlet: This must be the value returned by the
jakarta.servlet.ServletContext
methodgetMimeType()
.- Overrides:
getMimeType
in classExternalContext
- Parameters:
file
- The file for which the mime type should be obtained.- Returns:
- the MIME type of the file.
- See Also:
-
getRemoteUser
Description copied from class:ExternalContext
Return the login name of the user making the current request if any; otherwise, return
null
.Jakarta Servlet: This must be the value returned by the
jakarta.servlet.http.HttpServletRequest
methodgetRemoteUser()
.- Specified by:
getRemoteUser
in classExternalContext
- Returns:
- the user name of the current request.
- See Also:
-
getUserPrincipal
Description copied from class:ExternalContext
Return the
Principal
object containing the name of the current authenticated user, if any; otherwise, returnnull
.Jakarta Servlet: This must be the value returned by the
jakarta.servlet.http.HttpServletRequest
methodgetUserPrincipal()
.- Specified by:
getUserPrincipal
in classExternalContext
- Returns:
- the
Principal
object. - See Also:
-
isUserInRole
Description copied from class:ExternalContext
Return
true
if the currently authenticated user is included in the specified role. Otherwise, returnfalse
.Jakarta Servlet: This must be the value returned by the
jakarta.servlet.http.HttpServletRequest
methodisUserInRole(role)
.- Specified by:
isUserInRole
in classExternalContext
- Parameters:
role
- Logical role name to be checked- Returns:
- the flag indicating whether the current user is in the specified role.
- See Also:
-
invalidateSession
public void invalidateSession()Description copied from class:ExternalContext
Invalidates this session then unbinds any objects bound to it.
Jakarta Servlet: This must be the value returned by the
jakarta.servlet.http.HttpSession
methodinvalidate()
.The default implementation throws
UnsupportedOperationException
and is provided for the sole purpose of not breaking existing applications that extend this class.- Overrides:
invalidateSession
in classExternalContext
- See Also:
-
addResponseCookie
Description copied from class:ExternalContext
Adds the cookie represented by the arguments to the response.
Jakarta Servlet: This must be accomplished by calling the
jakarta.servlet.http.HttpServletResponse
methodaddCookie()
. TheCookie
argument must be constructed by passing thename
andvalue
parameters. If theproperties
arugument is non-null
and not empty, theCookie
instance must be initialized as described below.Cookie handling table Key in "values" Map
(case sensitive)Expected type of value. Name of setter method on Cookie
instance 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 any other attribute (e.g. SameSite) String setAttribute The default implementation throws
UnsupportedOperationException
and is provided for the sole purpose of not breaking existing applications that extend this class.- Overrides:
addResponseCookie
in classExternalContext
- Parameters:
name
- To be passed as the first argument to theCookie
constructor.value
- To be passed as the second argument to theCookie
constructor.properties
- AMap
containg key/value pairs to be passed as arguments to the setter methods as described above.- See Also:
-
getResponseOutputStream
Description copied from class:ExternalContext
Returns an
OutputStream
suitable for writing binary data to the user-agent.Jakarta Servlet: This must return the value returned by the
jakarta.servlet.ServletResponse
methodgetOutputStream()
.The default implementation throws
UnsupportedOperationException
and is provided for the sole purpose of not breaking existing applications that extend this class.- Overrides:
getResponseOutputStream
in classExternalContext
- Returns:
- the
OutputStream
for the current response. - Throws:
IOException
- any IO related exception.- See Also:
-
getResponseOutputWriter
Description copied from class:ExternalContext
Returns a
Writer
suitable for writing character data to the user-agent.Jakarta Servlet: This must return the value returned by the
ServletResponse.getWriter()
.The default implementation throws
UnsupportedOperationException
and is provided for the sole purpose of not breaking existing applications that extend this class.- Overrides:
getResponseOutputWriter
in classExternalContext
- Returns:
- the
Writer
for the current response. - Throws:
IOException
- any IO related exception.- See Also:
-
getRequestScheme
Description copied from class:ExternalContext
Returns the name of the scheme used to make this request, for example, http, https, or ftp.
Jakarta Servlet: This must be the value returned by the
jakarta.servlet.ServletRequest
methodgetScheme()
.The default implementation throws
UnsupportedOperationException
and is provided for the sole purpose of not breaking existing applications that extend this class.- Overrides:
getRequestScheme
in classExternalContext
- Returns:
- the name of the scheme.
- See Also:
-
getRequestServerName
Description copied from class:ExternalContext
Returns the host name of the server to which the request was sent.
Jakarta Servlet: This must be the value returned by the
jakarta.servlet.ServletRequest
methodgetServerName()
.The default implementation throws
UnsupportedOperationException
and is provided for the sole purpose of not breaking existing applications that extend this class.- Overrides:
getRequestServerName
in classExternalContext
- Returns:
- the host name of the server.
- See Also:
-
getRequestServerPort
public int getRequestServerPort()Description copied from class:ExternalContext
Returns the port number to which the request was sent.
Jakarta Servlet: This must be the value returned by the
jakarta.servlet.ServletRequest
methodgetServerPort()
.The default implementation throws
UnsupportedOperationException
and is provided for the sole purpose of not breaking existing applications that extend this class.- Overrides:
getRequestServerPort
in classExternalContext
- Returns:
- the port number to which the request was sent.
- See Also:
-
setResponseContentType
Description copied from class:ExternalContext
Sets the content type of the response being sent to the client, if the response has not been committed yet.
Jakarta Servlet: This must call
setContentType()
on the underlyingjakarta.servlet.ServletResponse
instance.The default implementation throws
UnsupportedOperationException
and is provided for the sole purpose of not breaking existing applications that extend this class.- Overrides:
setResponseContentType
in classExternalContext
- Parameters:
contentType
- The content type to be set as the contentType of the response.- See Also:
-
setResponseHeader
Description copied from class:ExternalContext
Set the response header with the given name and value.
Jakarta Servlet:This must be performed by calling the
jakarta.servlet.http.HttpServletResponse
setHeader
method.The default implementation throws
UnsupportedOperationException
and is provided for the sole purpose of not breaking existing applications that extend this class.- Overrides:
setResponseHeader
in classExternalContext
- Parameters:
name
- The name of the response header.value
- The value of the response header.- See Also:
-
addResponseHeader
Description copied from class:ExternalContext
Add the given name and value to the response header.
Jakarta Servlet:This must be performed by calling the
jakarta.servlet.http.HttpServletResponse
addHeader
method.The default implementation throws
UnsupportedOperationException
and is provided for the sole purpose of not breaking existing applications that extend this class.- Overrides:
addResponseHeader
in classExternalContext
- Parameters:
name
- The name of the response header.value
- The value of the response header.- See Also:
-
setResponseBufferSize
public void setResponseBufferSize(int size) Description copied from class:ExternalContext
Set the buffer size for the current response.
Jakarta Servlet: This must be performed by calling the
jakarta.servlet.http.HttpServletResponse
setBufferSize
method.The default implementation throws
UnsupportedOperationException
and is provided for the sole purpose of not breaking existing applications that extend this class.- Overrides:
setResponseBufferSize
in classExternalContext
- Parameters:
size
- the new buffer size- See Also:
-
isResponseCommitted
public boolean isResponseCommitted()Description copied from class:ExternalContext
Check if the current response has been committed.
Jakarta Servlet: This must be performed by calling the
jakarta.servlet.http.HttpServletResponse
isCommitted
method.The default implementation throws
UnsupportedOperationException
and is provided for the sole purpose of not breaking existing applications that extend this class.- Overrides:
isResponseCommitted
in classExternalContext
- Returns:
- the flag indicating whether the current response has been committed.
- See Also:
-
responseReset
public void responseReset()Description copied from class:ExternalContext
Resets the current response.
Jakarta Servlet: This must be performed by calling the
jakarta.servlet.http.HttpServletResponse
reset
method.The default implementation throws
UnsupportedOperationException
and is provided for the sole purpose of not breaking existing applications that extend this class.- Overrides:
responseReset
in classExternalContext
- See Also:
-
responseSendError
Description copied from class:ExternalContext
Sends an HTTP status code with message.
Jakarta Servlet: This must be performed by calling the
jakarta.servlet.http.HttpServletResponse
sendError
method.The default implementation throws
UnsupportedOperationException
and is provided for the sole purpose of not breaking existing applications that extend this class.- Overrides:
responseSendError
in classExternalContext
- Parameters:
statusCode
- an HTTP status codemessage
- an option message to detail the cause of the code- Throws:
IOException
- any IO related exceptions.- See Also:
-
setResponseStatus
public void setResponseStatus(int statusCode) Description copied from class:ExternalContext
Sets the HTTP status code for the response.
Jakarta Servlet: This must be performed by calling the
jakarta.servlet.http.HttpServletResponse
setStatus
method.The default implementation throws
UnsupportedOperationException
and is provided for the sole purpose of not breaking existing applications that extend this class.- Overrides:
setResponseStatus
in classExternalContext
- Parameters:
statusCode
- an HTTP status code- See Also:
-
responseFlushBuffer
Description copied from class:ExternalContext
Flushes the buffered response content to the client.
Jakarta Servlet: This must be performed by calling the
jakarta.servlet.http.HttpServletResponse
flushBuffer
method.The default implementation throws
UnsupportedOperationException
and is provided for the sole purpose of not breaking existing applications that extend this class.- Overrides:
responseFlushBuffer
in classExternalContext
- Throws:
IOException
- any IO related exception.- See Also:
-
setResponseContentLength
public void setResponseContentLength(int length) Description copied from class:ExternalContext
Set the content length of the response as an int
Jakarta Servlet: This must be performed by calling the
jakarta.servlet.http.HttpServletResponse
setContentLength
method.The default implementation throws
UnsupportedOperationException
and is provided for the sole purpose of not breaking existing applications that extend this class.- Overrides:
setResponseContentLength
in classExternalContext
- Parameters:
length
- the value to be set.- See Also:
-
setResponseContentLengthLong
public void setResponseContentLengthLong(long length) Description copied from class:ExternalContext
Set the content length of the response as a long.
Jakarta Servlet: This must be performed by calling the
jakarta.servlet.http.HttpServletResponse
setContentLengthLong
method.The default implementation throws
UnsupportedOperationException
and is provided for the sole purpose of not breaking existing applications that extend this class.- Overrides:
setResponseContentLengthLong
in classExternalContext
- Parameters:
length
- the value to be set.- See Also:
-
setSessionMaxInactiveInterval
public void setSessionMaxInactiveInterval(int interval) Description copied from class:ExternalContext
Specifies the time, in seconds, between client requests before the Jakarta Servlet container will invalidate this session.
An interval value of zero or less indicates that the session should never timeout.
Jakarta Servlet: This must call
setMaxInactiveInterval
on the underlyingjakarta.servlet.http.HttpServletRequest
instance.The default implementation throws
UnsupportedOperationException
and is provided for the sole purpose of not breaking existing applications that extend this class.- Overrides:
setSessionMaxInactiveInterval
in classExternalContext
- Parameters:
interval
- the value to be set.- See Also:
-
getResponseBufferSize
public int getResponseBufferSize()Description copied from class:ExternalContext
Return the buffer size for the current response.
Jakarta Servlet: This must be performed by calling the
jakarta.servlet.http.HttpServletResponse
getBufferSize
method.The default implementation throws
UnsupportedOperationException
and is provided for the sole purpose of not breaking existing applications that extend this class.- Overrides:
getResponseBufferSize
in classExternalContext
- Returns:
- the buffer size of the response.
- See Also:
-
getSessionMaxInactiveInterval
public int getSessionMaxInactiveInterval()Description copied from class:ExternalContext
Returns the maximum time interval, in seconds, that the Jakarta Servlet container will keep this session open between client accesses. After this interval, the Jakarta Servlet container will invalidate the session. The maximum time interval can be set with the
ExternalContext.setSessionMaxInactiveInterval(int)
method.A return value of zero or less indicates that the session will never timeout.
Jakarta Servlet: This must return the result of calling
getMaxInactiveInterval
on the underlyingjakarta.servlet.http.HttpSession
instance.The default implementation throws
UnsupportedOperationException
and is provided for the sole purpose of not breaking existing applications that extend this class.- Overrides:
getSessionMaxInactiveInterval
in classExternalContext
- Returns:
- the session maximum inactive interval.
- See Also:
-
isSecure
public boolean isSecure()Description copied from class:ExternalContext
Returns a boolean indicating whether this request was made using a secure channel, such as HTTPS.
Jakarta Servlet: This must return the result of calling
isSecure
on the underlyingjakarta.servlet.http.HttpServletRequest
instance.The default implementation throws
UnsupportedOperationException
and is provided for the sole purpose of not breaking existing applications that extend this class.- Overrides:
isSecure
in classExternalContext
- Returns:
- boolean
- See Also:
-
encodeBookmarkableURL
Description copied from class:ExternalContext
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 Jakarta Faces 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
ExternalContext.encodeActionURL(java.lang.String)
for the required specification of how to encode theClientWindow
.The default implementation throws
UnsupportedOperationException
and is provided for the sole purpose of not breaking existing applications that extend this class.- Overrides:
encodeBookmarkableURL
in classExternalContext
- 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- Returns:
- the result of encoding.
-
encodeRedirectURL
Description copied from class:ExternalContext
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
ExternalContext.encodeActionURL(java.lang.String)
for the required specification of how to encode theClientWindow
.- Overrides:
encodeRedirectURL
in classExternalContext
- 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- Returns:
- the result of encoding.
-
encodePartialActionURL
Description copied from class:ExternalContext
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
ExternalContext.encodeActionURL(java.lang.String)
for the required specification of how to encode theClientWindow
.Jakarta Servlet:Returns the same encoded URL as the
ExternalContext.encodeActionURL(String url)
method.Portlet:Returns an encoded URL that, upon HTTP POST, will invoke the RESOURCE_PHASE of the portlet lifecycle.
- Overrides:
encodePartialActionURL
in classExternalContext
- Parameters:
url
- The input URL to be encoded- Returns:
- the encoded URL.
- See Also:
-
getFlash
Description copied from class:ExternalContext
Return the threadsafe
Flash
for this application. The default implementation will throwUnsupportedOperationException
. Compliant Jakarta Faces runtimes must provide an implementation of this method.- Overrides:
getFlash
in classExternalContext
- Returns:
- the
Flash
for this application.
-
release
public void release()Description copied from class:ExternalContext
Release any resources associated with this
ExternalContext
instance. This method is called during during destruction of the associatedFacesContext
.- Specified by:
release
in classExternalContext
-