Top Description Inners Fields Constructors Methods
com.sun.faces.context

public Class ExternalContextImpl

extends ExternalContext
Class Inheritance
Static Imports
com.sun.faces.RIConstants.PUSH_RESOURCE_URLS_KEY_NAME, com.sun.faces.context.ContextParam.SendPoweredByHeader, .UrlBuilder.PROTOCOL_SEPARATOR, .UrlBuilder.WEBSOCKET_PROTOCOL, com.sun.faces.util.Util.isEmpty

This implementation of ExternalContext is specific to the servlet implementation.

Nested and Inner Type Summary

Modifier and TypeClass and Description

Field Summary

Modifier and TypeField and Description
private Map<String, Object>
private ClientWindow
private Map<String, Object>
private final boolean
private static final Map<String, String>
private Flash
private Map<String, String>
private static final Logger
private ServletRequest
private Map<String, String>
private Map<String, String[]>
private Map<String, Object>
private Map<String, String>
private Map<String, String[]>
private ServletResponse
private ServletContext
private Map<String, Object>
pack-priv static final Class<T>
Inherited from jakarta.faces.context.ExternalContext:
BASIC_AUTHCLIENT_CERT_AUTHDIGEST_AUTHFORM_AUTH

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public void
addResponseCookie(String
To be passed as the first argument to the Cookie constructor.
name
,
String
To be passed as the second argument to the Cookie constructor.
value
,
Map<String, Object>
A Map containg key/value pairs to be passed as arguments to the setter methods as described above.
properties
)

Overrides jakarta.faces.context.ExternalContext.addResponseCookie.

Adds the cookie represented by the arguments to the response.

public void
addResponseHeader(String
The name of the response header.
name
,
String
The value of the response header.
value
)

Overrides jakarta.faces.context.ExternalContext.addResponseHeader.

Add the given name and value to the response header.

public void
dispatch(String
Context relative path to the specified resource, which must start with a slash ("/") character
requestURI
)

Implements abstract jakarta.faces.context.ExternalContext.dispatch.

Dispatch a request to the specified resource to create output for this response.

private void
doLastPhaseActions(FacesContext context, boolean outgoingResponseIsRedirect)

public String
encodeActionURL(String
The input URL to be encoded
url
)

Implements abstract jakarta.faces.context.ExternalContext.encodeActionURL.

Return the input URL, after performing any rewriting needed to ensure that it will correctly identify an addressable action in the current application.

public String
encodeBookmarkableURL(String
The base URL onto which the query string generated by this method will be appended. The URL may contain query parameters.
baseUrl
,
Map<String, List<String>>
The collection of Parameter objects, representing name=value pairs that are used to produce a query string
parameters
)

Overrides jakarta.faces.context.ExternalContext.encodeBookmarkableURL.

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.

public String
encodeNamespace(String
Name to be encoded
name
)

Implements abstract jakarta.faces.context.ExternalContext.encodeNamespace.

Return the specified name, after prefixing it with a namespace that ensures that it will be unique within the context of a particular page.

public String
encodePartialActionURL(String
The input URL to be encoded
url
)

Overrides jakarta.faces.context.ExternalContext.encodePartialActionURL.

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.

public String
encodeRedirectURL(String
The base URL onto which the query string generated by this method will be appended. The URL may contain query parameters.
baseUrl
,
Map<String, List<String>>
The collection of Parameter objects, representing name=value pairs that are used to produce a query string
parameters
)

Overrides jakarta.faces.context.ExternalContext.encodeRedirectURL.

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.

public String
encodeResourceURL(String
The input URL to be encoded
url
)

Implements abstract jakarta.faces.context.ExternalContext.encodeResourceURL.

Return the input URL, after performing any rewriting needed to ensure that it will correctly identify an addressable resource in the current application.

public String
encodeWebsocketURL(String
The input URL to be encoded.
url
)

Implements abstract jakarta.faces.context.ExternalContext.encodeWebsocketURL.

Return the websocket URL, after performing any rewriting needed to ensure that it will correctly identify an addressable websocket in the current application.

public String
getApplicationContextPath()

Overrides jakarta.faces.context.ExternalContext.getApplicationContextPath.

Return the name of the container context for this application.

public Map<String, Object>
getApplicationMap()

Implements abstract jakarta.faces.context.ExternalContext.getApplicationMap.

Return a mutable Map representing the application scope attributes for the current application.

public String
getAuthType()

Implements abstract jakarta.faces.context.ExternalContext.getAuthType.

Return the name of the authentication scheme used to authenticate the current user, if any; otherwise, return null.

public ClientWindow
getClientWindow()

Overrides jakarta.faces.context.ExternalContext.getClientWindow.

Return the ClientWindow set in a preceding call to setClientWindow, or null if no such call has been made.

public Object
getContext()

Implements abstract jakarta.faces.context.ExternalContext.getContext.

Return the application environment object instance for the current appication.

public String
getContextName()

Overrides jakarta.faces.context.ExternalContext.getContextName.

Return the name of the container context for this application.

private static String
public Flash
getFlash()

Overrides jakarta.faces.context.ExternalContext.getFlash.

Return the threadsafe Flash for this application.

public String
getInitParameter(String
Name of the requested initialization parameter
name
)

Implements abstract jakarta.faces.context.ExternalContext.getInitParameter.

Return the value of the specified application initialization parameter (if any).

public Map<String, String>
getInitParameterMap()

Implements abstract jakarta.faces.context.ExternalContext.getInitParameterMap.

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.

public String
getMimeType(String
The file for which the mime type should be obtained.
file
)

Overrides jakarta.faces.context.ExternalContext.getMimeType.

Returns the MIME type of the specified file or null if the MIME type is not known.

private PushBuilder
getPushBuilder(FacesContext context)
References Deprecated PushBuilder is deprecated or references (maybe indirectly) at least one deprecated element.

public String
getRealPath(String
The context of the requested initialization parameter
path
)

Overrides jakarta.faces.context.ExternalContext.getRealPath.

Returns a String containing the real path for a given virtual path.

public String
getRemoteUser()

Implements abstract jakarta.faces.context.ExternalContext.getRemoteUser.

Return the login name of the user making the current request if any; otherwise, return null.

public Object
getRequest()

Implements abstract jakarta.faces.context.ExternalContext.getRequest.

Return the environment-specific object instance for the current request.

public String
getRequestCharacterEncoding()

Overrides jakarta.faces.context.ExternalContext.getRequestCharacterEncoding.

Return the character encoding currently being used to interpret this request.

public int
getRequestContentLength()

Overrides jakarta.faces.context.ExternalContext.getRequestContentLength.

Return the result of calling getContentLenth() on the ServletRequest instance for this request.

public String
getRequestContentType()

Overrides jakarta.faces.context.ExternalContext.getRequestContentType.

Return the MIME Content-Type for this request.

public String
getRequestContextPath()

Implements abstract jakarta.faces.context.ExternalContext.getRequestContextPath.

Return the portion of the request URI that identifies the web application context for this request.

public Map<String, Object>
getRequestCookieMap()

Implements abstract jakarta.faces.context.ExternalContext.getRequestCookieMap.

Return an immutable Map whose keys are the set of cookie names included in the current request, and whose values (of type jakarta.servlet.http.Cookie) are the first (or only) cookie for each cookie name returned by the underlying request.

public Map<String, String>
getRequestHeaderMap()

Implements abstract jakarta.faces.context.ExternalContext.getRequestHeaderMap.

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.

public Map<String, String[]>
getRequestHeaderValuesMap()

Implements abstract jakarta.faces.context.ExternalContext.getRequestHeaderValuesMap.

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.

public Locale
getRequestLocale()

Implements abstract jakarta.faces.context.ExternalContext.getRequestLocale.

Return the preferred Locale in which the client will accept content.

public Iterator<Locale>
getRequestLocales()

Implements abstract jakarta.faces.context.ExternalContext.getRequestLocales.

Return an Iterator over the preferred Locales specified in the request, in decreasing order of preference.

public Map<String, Object>
getRequestMap()

Implements abstract jakarta.faces.context.ExternalContext.getRequestMap.

Return a mutable Map representing the request scope attributes for the current application.

public Map<String, String>
getRequestParameterMap()

Implements abstract jakarta.faces.context.ExternalContext.getRequestParameterMap.

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.

public Iterator<String>
getRequestParameterNames()

Implements abstract jakarta.faces.context.ExternalContext.getRequestParameterNames.

Return an Iterator over the names of all request parameters included in the current request.

public Map<String, String[]>
getRequestParameterValuesMap()

Implements abstract jakarta.faces.context.ExternalContext.getRequestParameterValuesMap.

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.

public String
getRequestPathInfo()

Implements abstract jakarta.faces.context.ExternalContext.getRequestPathInfo.

Return the extra path information (if any) included in the request URI; otherwise, return null.

public String
getRequestScheme()

Overrides jakarta.faces.context.ExternalContext.getRequestScheme.

Returns the name of the scheme used to make this request, for example, http, https, or ftp.

public String
getRequestServerName()

Overrides jakarta.faces.context.ExternalContext.getRequestServerName.

Returns the host name of the server to which the request was sent.

public int
getRequestServerPort()

Overrides jakarta.faces.context.ExternalContext.getRequestServerPort.

Returns the port number to which the request was sent.

public String
getRequestServletPath()

Implements abstract jakarta.faces.context.ExternalContext.getRequestServletPath.

Return the Jakarta Servlet path information (if any) included in the request URI; otherwise, return null.

public URL
getResource(String
The path to the requested resource, which must start with a slash ("/" character
path
)

Implements abstract jakarta.faces.context.ExternalContext.getResource.

Return a URL for the application resource mapped to the specified path, if it exists; otherwise, return null.

public InputStream
getResourceAsStream(String
The path to the requested resource, which must start with a slash ("/" character
path
)

Implements abstract jakarta.faces.context.ExternalContext.getResourceAsStream.

Return an InputStream for an application resource mapped to the specified path, if it exists; otherwise, return null.

public Set<String>
getResourcePaths(String
Partial path used to match resources, which must start with a slash ("/") character
path
)

Implements abstract jakarta.faces.context.ExternalContext.getResourcePaths.

Return the Set of resource paths for all application resources whose resource path starts with the specified argument.

public Object
getResponse()

Implements abstract jakarta.faces.context.ExternalContext.getResponse.

Return the environment-specific object instance for the current response.

public int
getResponseBufferSize()

Overrides jakarta.faces.context.ExternalContext.getResponseBufferSize.

Return the buffer size for the current response.

public String
getResponseCharacterEncoding()

Overrides jakarta.faces.context.ExternalContext.getResponseCharacterEncoding.

Returns the name of the character encoding (MIME charset) used for the body sent in this response.

public String
getResponseContentType()

Overrides jakarta.faces.context.ExternalContext.getResponseContentType.

Return the MIME Content-Type for this response.

public OutputStream
getResponseOutputStream()

Overrides jakarta.faces.context.ExternalContext.getResponseOutputStream.

Returns an OutputStream suitable for writing binary data to the user-agent.

public Writer
getResponseOutputWriter()

Overrides jakarta.faces.context.ExternalContext.getResponseOutputWriter.

Returns a Writer suitable for writing character data to the user-agent.

public Object
getSession(boolean
Flag indicating whether or not a new session should be created if there is no session associated with the current request
create
)

Implements abstract jakarta.faces.context.ExternalContext.getSession.

If the create parameter is true, create (if necessary) and return a session instance associated with the current request.

public String
getSessionId(boolean
Flag indicating whether or not a new session should be created if there is no session associated with the current request
create
)

Overrides jakarta.faces.context.ExternalContext.getSessionId.

Return the id of the current session or the empty string if no session has been created and the create parameter is false.

public Map<String, Object>
getSessionMap()

Implements abstract jakarta.faces.context.ExternalContext.getSessionMap.

Return a mutable Map representing the session scope attributes for the current application.

public int
getSessionMaxInactiveInterval()

Overrides jakarta.faces.context.ExternalContext.getSessionMaxInactiveInterval.

Returns the maximum time interval, in seconds, that the Jakarta Servlet container will keep this session open between client accesses.

public Principal
getUserPrincipal()

Implements abstract jakarta.faces.context.ExternalContext.getUserPrincipal.

Return the Principal object containing the name of the current authenticated user, if any; otherwise, return null.

public void
invalidateSession()

Overrides jakarta.faces.context.ExternalContext.invalidateSession.

Invalidates this session then unbinds any objects bound to it.

public boolean
isResponseCommitted()

Overrides jakarta.faces.context.ExternalContext.isResponseCommitted.

Check if the current response has been committed.

public boolean

Returns:

boolean
isSecure
()

Overrides jakarta.faces.context.ExternalContext.isSecure.

Returns a boolean indicating whether this request was made using a secure channel, such as HTTPS.

public boolean
isUserInRole(String
Logical role name to be checked
role
)

Implements abstract jakarta.faces.context.ExternalContext.isUserInRole.

Return true if the currently authenticated user is included in the specified role.

public void
log(String
Message to be logged
message
)

Implements abstract jakarta.faces.context.ExternalContext.log.

Log the specified message to the application object.

public void
log(String
Message to be logged
message
,
Throwable
Exception to be logged
throwable
)

Implements abstract jakarta.faces.context.ExternalContext.log.

Log the specified message and exception to the application object.

private void
public void
redirect(String
Absolute URL to which the client should be redirected
requestURI
)

Implements abstract jakarta.faces.context.ExternalContext.redirect.

Redirect a request to the specified URL, and cause the responseComplete() method to be called on the FacesContext instance for the current request.

public void
release()

Implements abstract jakarta.faces.context.ExternalContext.release.

Release any resources associated with this ExternalContext instance.

public void
responseFlushBuffer()

Overrides jakarta.faces.context.ExternalContext.responseFlushBuffer.

Flushes the buffered response content to the client.

public void
responseReset()

Overrides jakarta.faces.context.ExternalContext.responseReset.

Resets the current response.

public void
responseSendError(int
an HTTP status code
statusCode
,
String
an option message to detail the cause of the code
message
)

Overrides jakarta.faces.context.ExternalContext.responseSendError.

Sends an HTTP status code with message.

public void
setClientWindow(ClientWindow
the window with which this instance is associated.
window
)

Overrides jakarta.faces.context.ExternalContext.setClientWindow.

Associate this instance with a ClientWindow.

public void
setRequest(Object
the request object to be set.
request
)

Overrides jakarta.faces.context.ExternalContext.setRequest.

Set the environment-specific request to be returned by subsequent calls to getRequest.

public void
setRequestCharacterEncoding(String
the encoding name to be set.
encoding
)

Overrides jakarta.faces.context.ExternalContext.setRequestCharacterEncoding.

Overrides the name of the character encoding used in the body of this request.

public void
setResponse(Object
the response instance to be set.
response
)

Overrides jakarta.faces.context.ExternalContext.setResponse.

Set the environment-specific response to be returned by subsequent calls to getResponse.

public void
setResponseBufferSize(int
the new buffer size
size
)

Overrides jakarta.faces.context.ExternalContext.setResponseBufferSize.

Set the buffer size for the current response.

public void
setResponseCharacterEncoding(String
the character encoding to be sent by the current response.
encoding
)

Overrides jakarta.faces.context.ExternalContext.setResponseCharacterEncoding.

Sets the character encoding (MIME charset) of the response being sent to the client, for example, to UTF-8.

public void
setResponseContentLength(int
the value to be set.
length
)

Overrides jakarta.faces.context.ExternalContext.setResponseContentLength.

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.

public void
setResponseContentLengthLong(long
the value to be set.
length
)

Overrides jakarta.faces.context.ExternalContext.setResponseContentLengthLong.

Set the content length of the response as a long.

public void
setResponseContentType(String
The content type to be set as the contentType of the response.
contentType
)

Overrides jakarta.faces.context.ExternalContext.setResponseContentType.

Sets the content type of the response being sent to the client, if the response has not been committed yet.

public void
setResponseHeader(String
The name of the response header.
name
,
String
The value of the response header.
value
)

Overrides jakarta.faces.context.ExternalContext.setResponseHeader.

Set the response header with the given name and value.

public void
setResponseStatus(int
an HTTP status code
statusCode
)

Overrides jakarta.faces.context.ExternalContext.setResponseStatus.

Sets the HTTP status code for the response.

public void
setSessionMaxInactiveInterval(int
the value to be set.
interval
)

Overrides jakarta.faces.context.ExternalContext.setSessionMaxInactiveInterval.

Specifies the time, in seconds, between client requests before the Jakarta Servlet container will invalidate this session.