Class ServletContextAdapter
public class ServletContextAdapter extends ExternalContext
-
Field Summary
Fields inherited from class jakarta.faces.context.ExternalContext
BASIC_AUTH, CLIENT_CERT_AUTH, DIGEST_AUTH, FORM_AUTH -
Constructor Summary
Constructors Constructor Description ServletContextAdapter(jakarta.servlet.ServletContext servletContext) -
Method Summary
Modifier and Type Method Description voidaddResponseHeader(String name, String value)Add the given name and value to the response header.voiddispatch(String path)Dispatch a request to the specified resource to create output for this response.StringencodeActionURL(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.StringencodeNamespace(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.StringencodePartialActionURL(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.StringencodeResourceURL(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.StringencodeWebsocketURL(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.StringgetApplicationContextPath()Return the name of the container context for this application.Map<String,Object>getApplicationMap()Return a mutableMaprepresenting the application scope attributes for the current application.StringgetAuthType()Return the name of the authentication scheme used to authenticate the current user, if any; otherwise, returnnull.ObjectgetContext()Return the application environment object instance for the current appication.StringgetContextName()Return the name of the container context for this application.FlashgetFlash()Return the threadsafeFlashfor this application.StringgetInitParameter(String name)Return the value of the specified application initialization parameter (if any).Map<String,String>getInitParameterMap()Return an immutableMapwhose keys are the set of application initialization parameter names configured for this application, and whose values are the corresponding parameter values.StringgetMimeType(String file)Returns the MIME type of the specified file ornullif the MIME type is not known.StringgetRealPath(String path)Returns a String containing the real path for a given virtual path.StringgetRemoteUser()Return the login name of the user making the current request if any; otherwise, returnnull.ObjectgetRequest()Return the environment-specific object instance for the current request.StringgetRequestCharacterEncoding()Return the character encoding currently being used to interpret this request.intgetRequestContentLength()Return the result of callinggetContentLenth()on theServletRequestinstance for this request.StringgetRequestContentType()Return the MIME Content-Type for this request.StringgetRequestContextPath()Return the portion of the request URI that identifies the web application context for this request.Map<String,Object>getRequestCookieMap()Return an immutableMapwhose 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.Map<String,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.Map<String,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.LocalegetRequestLocale()Return the preferredLocalein which the client will accept content.Iterator<Locale>getRequestLocales()Return anIteratorover the preferredLocales specified in the request, in decreasing order of preference.Map<String,Object>getRequestMap()Return a mutableMaprepresenting the request scope attributes for the current application.Map<String,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.Iterator<String>getRequestParameterNames()Return anIteratorover the names of all request parameters included in the current request.Map<String,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.StringgetRequestPathInfo()Return the extra path information (if any) included in the request URI; otherwise, returnnull.StringgetRequestServletPath()Return the Jakarta Servlet path information (if any) included in the request URI; otherwise, returnnull.URLgetResource(String path)Return aURLfor the application resource mapped to the specified path, if it exists; otherwise, returnnull.InputStreamgetResourceAsStream(String path)Return anInputStreamfor an application resource mapped to the specified path, if it exists; otherwise, returnnull.Set<String>getResourcePaths(String path)Return theSetof resource paths for all application resources whose resource path starts with the specified argument.ObjectgetResponse()Return the environment-specific object instance for the current response.StringgetResponseCharacterEncoding()Returns the name of the character encoding (MIME charset) used for the body sent in this response.StringgetResponseContentType()Return the MIME Content-Type for this response.ObjectgetSession(boolean create)If thecreateparameter istrue, create (if necessary) and return a session instance associated with the current request.Map<String,Object>getSessionMap()Return a mutableMaprepresenting the session scope attributes for the current application.PrincipalgetUserPrincipal()Return thePrincipalobject containing the name of the current authenticated user, if any; otherwise, returnnull.booleanisUserInRole(String role)Returntrueif the currently authenticated user is included in the specified role.voidlog(String message)Log the specified message to the application object.voidlog(String message, Throwable exception)Log the specified message and exception to the application object.voidredirect(String url)Redirect a request to the specified URL, and cause theresponseComplete()method to be called on theFacesContextinstance for the current request.voidrelease()voidsetRequest(Object request)Set the environment-specific request to be returned by subsequent calls toExternalContext.getRequest().voidsetRequestCharacterEncoding(String requestCharacterEncoding)Overrides the name of the character encoding used in the body of this request.voidsetResponse(Object response)Set the environment-specific response to be returned by subsequent calls toExternalContext.getResponse().voidsetResponseCharacterEncoding(String responseCharacterEncoding)Sets the character encoding (MIME charset) of the response being sent to the client, for example, to UTF-8.voidsetResponseHeader(String name, String value)Set the response header with the given name and value.Methods inherited from class jakarta.faces.context.ExternalContext
addResponseCookie, encodeBookmarkableURL, encodeRedirectURL, getClientWindow, getRequestScheme, getRequestServerName, getRequestServerPort, getResponseBufferSize, getResponseOutputStream, getResponseOutputWriter, getSessionId, getSessionMaxInactiveInterval, invalidateSession, isResponseCommitted, isSecure, responseFlushBuffer, responseReset, responseSendError, setClientWindow, setResponseBufferSize, setResponseContentLength, setResponseContentType, setResponseStatus, setSessionMaxInactiveInterval
-
Constructor Details
-
ServletContextAdapter
public ServletContextAdapter(jakarta.servlet.ServletContext servletContext)
-
-
Method Details
-
dispatch
Description copied from class:ExternalContextDispatch a request to the specified resource to create output for this response.
Jakarta Servlet: This must be accomplished by calling the
jakarta.servlet.ServletContextmethodgetRequestDispatcher(path), and calling theforward()method on the resulting object.If the call to
getRequestDisatcher(path)returnsnull, send aServletResponse SC_NOT_FOUNDerror code.- Specified by:
dispatchin classExternalContext- Parameters:
path- Context relative path to the specified resource, which must start with a slash ("/") character- Throws:
IOException- if an input/output error occurs
-
release
public void release() -
encodeActionURL
Description copied from class:ExternalContextReturn 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(jakarta.faces.context.FacesContext). If the result isfalsetake 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.HttpServletResponsemethodencodeURL(url).- Specified by:
encodeActionURLin classExternalContext- Parameters:
url- The input URL to be encoded- Returns:
- the encoded URL.
-
encodeNamespace
Description copied from class:ExternalContextReturn 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:
encodeNamespacein classExternalContext- Parameters:
name- Name to be encoded- Returns:
- the unique name prefixed with namespace.
-
encodeResourceURL
Description copied from class:ExternalContextReturn 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.HttpServletResponsemethodencodeURL(url).- Specified by:
encodeResourceURLin classExternalContext- Parameters:
url- The input URL to be encoded- Returns:
- the encoded resource URL.
-
encodeWebsocketURL
Description copied from class:ExternalContextReturn 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:
encodeWebsocketURLin classExternalContext- Parameters:
url- The input URL to be encoded.- Returns:
- the encoded websocket URL.
-
getApplicationMap
Description copied from class:ExternalContextReturn 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 withjakarta.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.Jakarta Servlet: This must be the set of attributes available via the
jakarta.servlet.ServletContextmethodsgetAttribute(),getAttributeNames(),removeAttribute(), andsetAttribute().- Specified by:
getApplicationMapin classExternalContext- Returns:
- the map associated with the backed
ServletContext.
-
getFlash
Description copied from class:ExternalContextReturn the threadsafe
Flashfor this application. The default implementation will throwUnsupportedOperationException. Compliant Jakarta Server Faces runtimes must provide an implementation of this method.- Overrides:
getFlashin classExternalContext- Returns:
- the
Flashfor this application.
-
getApplicationContextPath
Description copied from class:ExternalContextReturn the name of the container context for this application.
Jakarta 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.- Overrides:
getApplicationContextPathin classExternalContext- Returns:
- the context path of this application.
-
getAuthType
Description copied from class:ExternalContextReturn 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.HttpServletRequestmethodgetAuthType().- Specified by:
getAuthTypein classExternalContext- Returns:
- the authentication type.
-
getMimeType
Description copied from class:ExternalContextReturns 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.Jakarta Servlet: This must be the value returned by the
jakarta.servlet.ServletContextmethodgetMimeType().- Overrides:
getMimeTypein classExternalContext- Parameters:
file- The file for which the mime type should be obtained.- Returns:
- the MIME type of the file.
-
getContext
Description copied from class:ExternalContextReturn 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.Jakarta Servlet: This must be the current application's
jakarta.servlet.ServletContextinstance.- Specified by:
getContextin classExternalContext- Returns:
- the object of the
ServletContext.
-
getContextName
Description copied from class:ExternalContextReturn 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.- Overrides:
getContextNamein classExternalContext- Returns:
- the name the
ServletContext.
-
getInitParameter
Description copied from class:ExternalContextReturn the value of the specified application initialization parameter (if any).
Jakarta Servlet: This must be the result of the
jakarta.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.
- Specified by:
getInitParameterin classExternalContext- Parameters:
name- Name of the requested initialization parameter- Returns:
- the value of the specified parameter.
-
getInitParameterMap
Description copied from class:ExternalContextReturn 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.Jakarta Servlet: This result must be as if it were synthesized by calling the
jakarta.servlet.ServletContextmethodgetInitParameterNames, and putting each configured parameter name/value pair into the result.- Specified by:
getInitParameterMapin classExternalContext- Returns:
- the init parameter map for this application.
-
getRemoteUser
Description copied from class:ExternalContextReturn 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.HttpServletRequestmethodgetRemoteUser().- Specified by:
getRemoteUserin classExternalContext- Returns:
- the user name of the current request.
-
getRequest
Description copied from class:ExternalContextReturn the environment-specific object instance for the current request.
Jakarta Servlet: This must be the current request's
jakarta.servlet.http.HttpServletRequestinstance.- Specified by:
getRequestin classExternalContext- Returns:
- the instance of the current request.
-
setRequest
Description copied from class:ExternalContextSet 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
UnsupportedOperationExceptionand is provided for the sole purpose of not breaking existing applications that extend this class.- Overrides:
setRequestin classExternalContext- Parameters:
request- the request object to be set.
-
getRequestContextPath
Description copied from class:ExternalContextReturn 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.HttpServletRequestmethodgetContextPath().- Specified by:
getRequestContextPathin classExternalContext- Returns:
- the context path for this request.
-
getRequestCookieMap
Description copied from class:ExternalContextReturn an immutable
Mapwhose 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 returnedMapmust 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.HttpServletRequestmethodgetCookies(), unlessnullwas returned, in which case this must be a zero-length array.- Specified by:
getRequestCookieMapin classExternalContext- Returns:
- the cookie map in the current request.
-
getRequestHeaderMap
Description copied from class:ExternalContextReturn 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.Jakarta Servlet: This must be the set of headers available via the
jakarta.servlet.http.HttpServletRequestmethodsgetHeader()andgetHeaderNames().- Specified by:
getRequestHeaderMapin classExternalContext- Returns:
- the header map in the current request.
-
getRequestHeaderValuesMap
Description copied from class:ExternalContextReturn 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.Jakarta Servlet: This must be the set of headers available via the
jakarta.servlet.http.HttpServletRequestmethodsgetHeaders()andgetHeaderNames().- Specified by:
getRequestHeaderValuesMapin classExternalContext- Returns:
- the header values map in the current request.
-
getRequestLocale
Description copied from class:ExternalContextReturn the preferred
Localein which the client will accept content.Jakarta Servlet: This must be the value returned by the
jakarta.servlet.ServletRequestmethodgetLocale().- Specified by:
getRequestLocalein classExternalContext- Returns:
- the
Localeof the current request.
-
getRequestLocales
Description copied from class:ExternalContextReturn an
Iteratorover the preferredLocales specified in the request, in decreasing order of preference.Jakarta Servlet: This must be an
Iteratorover the values returned by thejakarta.servlet.ServletRequestmethodgetLocales().- Specified by:
getRequestLocalesin classExternalContext- Returns:
- the
IteratorofLocales of the current request.
-
getRequestMap
Description copied from class:ExternalContextReturn 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 withjakarta.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.Jakarta Servlet: This must be the set of attributes available via the
jakarta.servlet.ServletRequestmethodsgetAttribute(),getAttributeNames(),removeAttribute(), andsetAttribute().- Specified by:
getRequestMapin classExternalContext- Returns:
- the map including the attributes of the current request.
-
getRequestParameterMap
Description copied from class:ExternalContextReturn 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.Jakarta Servlet: This must be the set of parameters available via the
jakarta.servlet.ServletRequestmethodsgetParameter()andgetParameterNames().- Specified by:
getRequestParameterMapin classExternalContext- Returns:
- the map for the current request parameters.
-
getRequestParameterNames
Description copied from class:ExternalContextReturn an
Iteratorover the names of all request parameters included in the current request.Jakarta Servlet: This must be an
Iteratorover the values returned by thejakarta.servlet.ServletRequestmethodgetParameterNames().- Specified by:
getRequestParameterNamesin classExternalContext- Returns:
- the
Iteratorfor the names of the current request parameters.
-
getRequestParameterValuesMap
Description copied from class:ExternalContextReturn 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.Jakarta Servlet: This must be the set of parameters available via the
jakarta.servlet.ServletRequestmethodsgetParameterValues()andgetParameterNames().- Specified by:
getRequestParameterValuesMapin classExternalContext- Returns:
- the map for the parameter values of the current request.
-
getRequestPathInfo
Description copied from class:ExternalContextReturn 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.HttpServletRequestmethodgetPathInfo().- Specified by:
getRequestPathInfoin classExternalContext- Returns:
- the path information of the current request.
-
getRequestServletPath
Description copied from class:ExternalContextReturn 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.HttpServletRequestmethodgetServletPath().- Specified by:
getRequestServletPathin classExternalContext- Returns:
- the Jakarta Servlet path information of the current request.
-
getRequestContentType
Description copied from class:ExternalContextReturn the MIME Content-Type for this request. If not available, return
null.Jakarta Servlet: This must return the value returned by the
jakarta.servlet.ServletRequestmethodgetContentType().The default implementation throws
UnsupportedOperationExceptionand is provided for the sole purpose of not breaking existing applications that extend this class.- Overrides:
getRequestContentTypein classExternalContext- Returns:
- the Content-Type for this request.
-
getResponseContentType
Description copied from class:ExternalContextReturn the MIME Content-Type for this response. If not available, return
null.Jakarta Servlet: This must return the value returned by the
jakarta.servlet.ServletResponsemethodgetContentType().The default implementation throws
UnsupportedOperationExceptionand is provided for the sole purpose of not breaking existing applications that extend this class.- Overrides:
getResponseContentTypein classExternalContext- Returns:
- the MIME Content-Type for this response.
-
getRequestContentLength
public int getRequestContentLength()Description copied from class:ExternalContextReturn 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.- Overrides:
getRequestContentLengthin classExternalContext- Returns:
- the content length of the current request.
-
getResource
Description copied from class:ExternalContextReturn 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.Jakarta Servlet: This must be the value returned by the
jakarta.servlet.ServletContextmethodgetResource(path).- Specified by:
getResourcein classExternalContext- Parameters:
path- The path to the requested resource, which must start with a slash ("/" character- Returns:
- the URL of the resource.
- Throws:
MalformedURLException- if the specified path is not in the correct form
-
getResourceAsStream
Description copied from class:ExternalContextReturn 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.Jakarta Servlet: This must be the value returned by the
jakarta.servlet.ServletContextmethodgetResourceAsStream(path).- Specified by:
getResourceAsStreamin classExternalContext- Parameters:
path- The path to the requested resource, which must start with a slash ("/" character- Returns:
- the
InputStreamfor the application resource.
-
getResourcePaths
Description copied from class:ExternalContextReturn 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.Jakarta Servlet: This must be the value returned by the
jakarta.servlet.ServletContextmethodgetResourcePaths(path).- Specified by:
getResourcePathsin classExternalContext- Parameters:
path- Partial path used to match resources, which must start with a slash ("/") character- Returns:
- the
Setof resource paths for the application resources.
-
getResponse
Description copied from class:ExternalContextReturn the environment-specific object instance for the current response.
Jakarta Servlet: This is the current request's
jakarta.servlet.http.HttpServletResponseinstance.- Specified by:
getResponsein classExternalContext- Returns:
- the instance of the current
jakarta.servlet.http.HttpServletResponse.
-
setResponse
Description copied from class:ExternalContextSet 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
UnsupportedOperationExceptionand is provided for the sole purpose of not breaking existing applications that extend this class.- Overrides:
setResponsein classExternalContext- Parameters:
response- the response instance to be set.
-
getSession
Description copied from class:ExternalContextIf 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.Jakarta Servlet: This must return the result of calling
getSession(create)on the underlyingjakarta.servlet.http.HttpServletRequestinstance.- Specified by:
getSessionin 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.
-
getSessionMap
Description copied from class:ExternalContextReturn 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 withjakarta.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.Jakarta Servlet: This must be the set of attributes available via the
jakarta.servlet.http.HttpSessionmethodsgetAttribute(),getAttributeNames(),removeAttribute(), andsetAttribute().- Specified by:
getSessionMapin classExternalContext- Returns:
- the session map for the current application.
-
getUserPrincipal
Description copied from class:ExternalContextReturn the
Principalobject 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.HttpServletRequestmethodgetUserPrincipal().- Specified by:
getUserPrincipalin classExternalContext- Returns:
- the
Principalobject.
-
isUserInRole
Description copied from class:ExternalContextReturn
trueif 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.HttpServletRequestmethodisUserInRole(role).- Specified by:
isUserInRolein classExternalContext- Parameters:
role- Logical role name to be checked- Returns:
- the flag indicating whether the current user is in the specified role.
-
log
Description copied from class:ExternalContextLog 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.Jakarta Servlet: This must be performed by calling the
jakarta.servlet.ServletContextmethodlog(String).- Specified by:
login classExternalContext- Parameters:
message- Message to be logged
-
log
Description copied from class:ExternalContextLog 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.Jakarta Servlet: This must be performed by calling the
jakarta.servlet.ServletContextmethodlog(String,Throwable).- Specified by:
login classExternalContext- Parameters:
message- Message to be loggedexception- Exception to be logged
-
redirect
Description copied from class:ExternalContextRedirect 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().Jakarta Servlet: For non
Ajaxrequests, this must be accomplished by calling thejakarta.servlet.http.HttpServletResponsemethodsendRedirect().For Ajax requests, the implementation must:- Get a
PartialResponseWriterinstance 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 theurlargument. - Call
PartialResponseWriter.endDocument()
- Specified by:
redirectin classExternalContext- Parameters:
url- Absolute URL to which the client should be redirected- Throws:
IOException- if an input/output error occurs
- Get a
-
getRequestCharacterEncoding
Description copied from class:ExternalContextReturn the character encoding currently being used to interpret this request.
Jakarta Servlet: This must return the value returned by the
jakarta.servlet.ServletRequestmethodgetCharacterEncoding().The default implementation throws
UnsupportedOperationExceptionand is provided for the sole purpose of not breaking existing applications that extend this class.- Overrides:
getRequestCharacterEncodingin classExternalContext- Returns:
- the character encoding currently being used.
-
setRequestCharacterEncoding
public void setRequestCharacterEncoding(String requestCharacterEncoding) throws UnsupportedEncodingExceptionDescription copied from class:ExternalContextOverrides 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.Jakarta Servlet: This must call through to the
jakarta.servlet.ServletRequestmethodsetCharacterEncoding().The default implementation throws
UnsupportedOperationExceptionand is provided for the sole purpose of not breaking existing applications that extend this class.- Overrides:
setRequestCharacterEncodingin classExternalContext- Parameters:
requestCharacterEncoding- the encoding name to be set.- Throws:
UnsupportedEncodingException- if this is not a valid encoding
-
getResponseCharacterEncoding
Description copied from class:ExternalContextReturns 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.ServletResponsemethodgetCharacterEncoding().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
UnsupportedOperationExceptionand is provided for the sole purpose of not breaking existing applications that extend this class.- Overrides:
getResponseCharacterEncodingin classExternalContext- Returns:
- the name of the character encoding.
-
setResponseCharacterEncoding
Description copied from class:ExternalContextSets 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.ServletResponsemethodsetCharacterEncoding().The default implementation throws
UnsupportedOperationExceptionand is provided for the sole purpose of not breaking existing applications that extend this class.- Overrides:
setResponseCharacterEncodingin classExternalContext- Parameters:
responseCharacterEncoding- the character encoding to be sent by the current response.
-
setResponseHeader
Description copied from class:ExternalContextSet the response header with the given name and value.
Jakarta Servlet:This must be performed by calling the
jakarta.servlet.http.HttpServletResponsesetHeadermethod.The default implementation throws
UnsupportedOperationExceptionand is provided for the sole purpose of not breaking existing applications that extend this class.- Overrides:
setResponseHeaderin classExternalContext- Parameters:
name- The name of the response header.value- The value of the response header.
-
addResponseHeader
Description copied from class:ExternalContextAdd the given name and value to the response header.
Jakarta Servlet:This must be performed by calling the
jakarta.servlet.http.HttpServletResponseaddHeadermethod.The default implementation throws
UnsupportedOperationExceptionand is provided for the sole purpose of not breaking existing applications that extend this class.- Overrides:
addResponseHeaderin classExternalContext- Parameters:
name- The name of the response header.value- The value of the response header.
-
encodePartialActionURL
Description copied from class:ExternalContextReturn 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:
encodePartialActionURLin classExternalContext- Parameters:
url- The input URL to be encoded- Returns:
- the encoded URL.
-
getRealPath
Description copied from class:ExternalContextReturns 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 (ServletContextorPortletContext) as the one used when callinggetRealPath()on theExternalContextreturned by theFacesContextduring an actual request.Jakarta Servlet: This must be the value returned by the
jakarta.servlet.ServletContextmethodgetRealPath().The default implementation throws
UnsupportedOperationExceptionand is provided for the sole purpose of not breaking existing applications that extend this class.- Overrides:
getRealPathin classExternalContext- Parameters:
path- The context of the requested initialization parameter- Returns:
- the real path for the specified virtual path.
-