Class ExternalContextImpl

java.lang.Object
jakarta.faces.context.ExternalContext
com.sun.faces.context.ExternalContextImpl

public class ExternalContextImpl extends ExternalContext

This implementation of ExternalContext is specific to the servlet implementation.

  • Constructor Details

    • ExternalContextImpl

      public ExternalContextImpl(jakarta.servlet.ServletContext sc, jakarta.servlet.ServletRequest request, jakarta.servlet.ServletResponse response)
  • Method Details

    • getSession

      public Object getSession(boolean create)
      Description copied from class: ExternalContext

      If the create parameter is true, create (if necessary) and return a session instance associated with the current request. If the create parameter is false return any existing session instance associated with the current request, or return null if there is no such session.

      Jakarta Servlet: This must return the result of calling getSession(create) on the underlying jakarta.servlet.http.HttpServletRequest instance.

      Specified by:
      getSession in class ExternalContext
      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

      public String getSessionId(boolean create)
      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 is false.

      Jakarta Servlet: If create is true, obtain a reference to the HttpSession for the current request (creating the session if necessary) and return its id. If create is false, 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 class ExternalContext
      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

      public Object 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 or PortletContext) as the one returned when calling getContext() on the ExternalContext returned by the FacesContext during an actual request.

      Jakarta Servlet: This must be the current application's jakarta.servlet.ServletContext instance.

      Specified by:
      getContext in class ExternalContext
      Returns:
      the object of the ServletContext.
      See Also:
    • getContextName

      public String getContextName()
      Description copied from class: ExternalContext

      Return the name of the container context for this application.

      Return the result of calling getServletContextName() on the ServletContext 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 class ExternalContext
      Returns:
      the name the ServletContext.
      See Also:
    • getRequest

      public Object 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 class ExternalContext
      Returns:
      the instance of the current request.
      See Also:
    • setRequest

      public void setRequest(Object request)
      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 class ExternalContext
      Parameters:
      request - the request object to be set.
      See Also:
    • setRequestCharacterEncoding

      public void setRequestCharacterEncoding(String encoding) throws UnsupportedEncodingException
      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 or Stream has been obtained from the request, in which case an IllegalStateException is thrown.

      Jakarta Servlet: This must call through to the jakarta.servlet.ServletRequest method setCharacterEncoding().

      The default implementation throws UnsupportedOperationException and is provided for the sole purpose of not breaking existing applications that extend this class.

      Overrides:
      setRequestCharacterEncoding in class ExternalContext
      Parameters:
      encoding - the encoding name to be set.
      Throws:
      UnsupportedEncodingException - if this is not a valid encoding
      See Also:
    • getResponse

      public Object 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 class ExternalContext
      Returns:
      the instance of the current jakarta.servlet.http.HttpServletResponse.
      See Also:
    • setResponse

      public void setResponse(Object response)
      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 class ExternalContext
      Parameters:
      response - the response instance to be set.
      See Also:
    • getClientWindow

      public ClientWindow getClientWindow()
      Description copied from class: ExternalContext

      Return the ClientWindow set in a preceding call to ExternalContext.setClientWindow(jakarta.faces.lifecycle.ClientWindow), or null if no such call has been made.

      Overrides:
      getClientWindow in class ExternalContext
      Returns:
      the instance of the ClientWindow.
    • setClientWindow

      public void setClientWindow(ClientWindow window)
      Description copied from class: ExternalContext

      Associate this instance with a ClientWindow.

      Overrides:
      setClientWindow in class ExternalContext
      Parameters:
      window - the window with which this instance is associated.
    • setResponseCharacterEncoding

      public void setResponseCharacterEncoding(String encoding)
      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 method setCharacterEncoding().

      The default implementation throws UnsupportedOperationException and is provided for the sole purpose of not breaking existing applications that extend this class.

      Overrides:
      setResponseCharacterEncoding in class ExternalContext
      Parameters:
      encoding - the character encoding to be sent by the current response.
      See Also:
    • getApplicationMap

      public Map<String,Object> getApplicationMap()
      Description copied from class: ExternalContext

      Return a mutable Map representing the application scope attributes for the current application. The returned Map must implement the entire contract for a modifiable map as described in the JavaDocs for java.util.Map. Modifications made in the Map must cause the corresponding changes in the set of application scope attributes. Particularly the clear(), remove(), put(), putAll(), and get() 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 or PortletContext) as the one returned by calling getApplicationMap() on the ExternalContext returned by the FacesContext during an actual request.

      Jakarta Servlet: This must be the set of attributes available via the jakarta.servlet.ServletContext methods getAttribute(), getAttributeNames(), removeAttribute(), and setAttribute().

      Specified by:
      getApplicationMap in class ExternalContext
      Returns:
      the map associated with the backed ServletContext.
      See Also:
    • getApplicationContextPath

      public String 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 the ServletContext 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 class ExternalContext
      Returns:
      the context path of this application.
    • getSessionMap

      public Map<String,Object> getSessionMap()
      Description copied from class: ExternalContext

      Return a mutable Map representing the session scope attributes for the current application. The returned Map must implement the entire contract for a modifiable map as described in the JavaDocs for java.util.Map. Modifications made in the Map must cause the corresponding changes in the set of session scope attributes. Particularly the clear(), remove(), put(), and get() operations must take the appropriate action on the underlying data structure. Accessing attributes via this Map 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 methods getAttribute(), getAttributeNames(), removeAttribute(), and setAttribute().

      Specified by:
      getSessionMap in class ExternalContext
      Returns:
      the session map for the current application.
      See Also:
    • getRequestMap

      public Map<String,Object> getRequestMap()
      Description copied from class: ExternalContext

      Return a mutable Map representing the request scope attributes for the current application. The returned Map must implement the entire contract for a modifiable map as described in the JavaDocs for java.util.Map. Modifications made in the Map must cause the corresponding changes in the set of request scope attributes. Particularly the clear(), remove(), put(), putAll(), and get() 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 methods getAttribute(), getAttributeNames(), removeAttribute(), and setAttribute().

      Specified by:
      getRequestMap in class ExternalContext
      Returns:
      the map including the attributes of the current request.
      See Also:
    • getRequestHeaderMap

      public Map<String,String> 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 returned Map must implement the entire contract for an unmodifiable map as described in the JavaDocs for java.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 methods getHeader() and getHeaderNames().

      Specified by:
      getRequestHeaderMap in class ExternalContext
      Returns:
      the header map in the current request.
      See Also:
    • getRequestHeaderValuesMap

      public Map<String,String[]> 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 returned Map must implement the entire contract for an unmodifiable map as described in the JavaDocs for java.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 methods getHeaders() and getHeaderNames().

      Specified by:
      getRequestHeaderValuesMap in class ExternalContext
      Returns:
      the header values map in the current request.
      See Also:
    • getRequestCookieMap

      public Map<String,Object> 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 type jakarta.servlet.http.Cookie) are the first (or only) cookie for each cookie name returned by the underlying request. The returned Map must implement the entire contract for an unmodifiable map as described in the JavaDocs for java.util.Map.

      Jakarta Servlet: This must be the value returned by the jakarta.servlet.http.HttpServletRequest method getCookies(), unless null was returned, in which case this must be a zero-length array.

      Specified by:
      getRequestCookieMap in class ExternalContext
      Returns:
      the cookie map in the current request.
      See Also:
    • getInitParameterMap

      public Map<String,String> 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 returned Map must implement the entire contract for an unmodifiable map as described in the JavaDocs for java.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 or PortletContext) as the one returned by calling getInitParameterMap() on the ExternalContext returned by the FacesContext during an actual request.

      Jakarta Servlet: This result must be as if it were synthesized by calling the jakarta.servlet.ServletContext method getInitParameterNames, and putting each configured parameter name/value pair into the result.

      Specified by:
      getInitParameterMap in class ExternalContext
      Returns:
      the init parameter map for this application.
      See Also:
    • getRequestParameterMap

      public Map<String,String> 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 returned Map must implement the entire contract for an unmodifiable map as described in the JavaDocs for java.util.Map.

      Jakarta Servlet: This must be the set of parameters available via the jakarta.servlet.ServletRequest methods getParameter() and getParameterNames().

      Specified by:
      getRequestParameterMap in class ExternalContext
      Returns:
      the map for the current request parameters.
      See Also:
    • getRequestParameterValuesMap

      public Map<String,String[]> 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 returned Map must implement the entire contract for an unmodifiable map as described in the JavaDocs for java.util.Map.

      Jakarta Servlet: This must be the set of parameters available via the jakarta.servlet.ServletRequest methods getParameterValues() and getParameterNames().

      Specified by:
      getRequestParameterValuesMap in class ExternalContext
      Returns:
      the map for the parameter values of the current request.
      See Also:
    • getRequestParameterNames

      public Iterator<String> 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 the jakarta.servlet.ServletRequest method getParameterNames().

      Specified by:
      getRequestParameterNames in class ExternalContext
      Returns:
      the Iterator for the names of the current request parameters.
      See Also:
    • getRequestLocale

      public Locale 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 method getLocale().

      Specified by:
      getRequestLocale in class ExternalContext
      Returns:
      the Locale of the current request.
      See Also:
    • getRequestLocales

      public Iterator<Locale> getRequestLocales()
      Description copied from class: ExternalContext

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

      Jakarta Servlet: This must be an Iterator over the values returned by the jakarta.servlet.ServletRequest method getLocales().

      Specified by:
      getRequestLocales in class ExternalContext
      Returns:
      the Iterator of Locales of the current request.
      See Also:
    • getRequestPathInfo

      public String 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 method getPathInfo().

      Specified by:
      getRequestPathInfo in class ExternalContext
      Returns:
      the path information of the current request.
      See Also:
    • getRealPath

      public String getRealPath(String path)
      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 or PortletContext) as the one used when calling getRealPath() on the ExternalContext returned by the FacesContext during an actual request.

      Jakarta Servlet: This must be the value returned by the jakarta.servlet.ServletContext method getRealPath().

      The default implementation throws UnsupportedOperationException and is provided for the sole purpose of not breaking existing applications that extend this class.

      Overrides:
      getRealPath in class ExternalContext
      Parameters:
      path - The context of the requested initialization parameter
      Returns:
      the real path for the specified virtual path.
      See Also:
    • getRequestContextPath

      public String 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 method getContextPath().

      Specified by:
      getRequestContextPath in class ExternalContext
      Returns:
      the context path for this request.
      See Also:
    • getRequestServletPath

      public String 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 method getServletPath().

      Specified by:
      getRequestServletPath in class ExternalContext
      Returns:
      the Jakarta Servlet path information of the current request.
      See Also:
    • getRequestCharacterEncoding

      public String 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 method getCharacterEncoding().

      The default implementation throws UnsupportedOperationException and is provided for the sole purpose of not breaking existing applications that extend this class.

      Overrides:
      getRequestCharacterEncoding in class ExternalContext
      Returns:
      the character encoding currently being used.
      See Also:
    • getRequestContentType

      public String 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 method getContentType().

      The default implementation throws UnsupportedOperationException and is provided for the sole purpose of not breaking existing applications that extend this class.

      Overrides:
      getRequestContentType in class ExternalContext
      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 the ServletRequest 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 class ExternalContext
      Returns:
      the content length of the current request.
      See Also:
    • getResponseCharacterEncoding

      public String 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 method getCharacterEncoding().

      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 class ExternalContext
      Returns:
      the name of the character encoding.
      See Also:
    • getResponseContentType

      public String 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 method getContentType().

      The default implementation throws UnsupportedOperationException and is provided for the sole purpose of not breaking existing applications that extend this class.

      Overrides:
      getResponseContentType in class ExternalContext
      Returns:
      the MIME Content-Type for this response.
      See Also:
    • getInitParameter

      public String getInitParameter(String name)
      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 method getInitParameter(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 class ExternalContext
      Parameters:
      name - Name of the requested initialization parameter
      Returns:
      the value of the specified parameter.
      See Also:
    • getResourcePaths

      public Set<String> getResourcePaths(String path)
      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 or PortletContext) as the one used when calling getResourcePaths() on the ExternalContext returned by the FacesContext during an actual request.

      Jakarta Servlet: This must be the value returned by the jakarta.servlet.ServletContext method getResourcePaths(path).

      Specified by:
      getResourcePaths in class ExternalContext
      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

      public InputStream getResourceAsStream(String path)
      Description copied from class: ExternalContext

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

      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 or PortletContext) as the one used when calling getResourceAsStream() on the ExternalContext returned by the FacesContext during an actual request.

      Jakarta Servlet: This must be the value returned by the jakarta.servlet.ServletContext method getResourceAsStream(path).

      Specified by:
      getResourceAsStream in class ExternalContext
      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

      public URL getResource(String path)
      Description copied from class: ExternalContext

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

      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 or PortletContext) as the one used when calling getResource() on the ExternalContext returned by the FacesContext during an actual request.

      Jakarta Servlet: This must be the value returned by the jakarta.servlet.ServletContext method getResource(path).

      Specified by:
      getResource in class ExternalContext
      Parameters:
      path - The path to the requested resource, which must start with a slash ("/" character
      Returns:
      the URL of the resource.
      See Also:
    • encodeActionURL

      public String encodeActionURL(String url)
      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 is false take no further action and return the rewritten URL. If the result is true, call ExternalContext.getClientWindow(). If the result is non-null, call ClientWindow.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 method encodeURL(url).

      Specified by:
      encodeActionURL in class ExternalContext
      Parameters:
      url - The input URL to be encoded
      Returns:
      the encoded URL.
      See Also:
    • encodeResourceURL

      public String encodeResourceURL(String url)
      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 method encodeURL(url).

      Specified by:
      encodeResourceURL in class ExternalContext
      Parameters:
      url - The input URL to be encoded
      Returns:
      the encoded resource URL.
      See Also:
    • encodeWebsocketURL

      public String encodeWebsocketURL(String url)
      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 class ExternalContext
      Parameters:
      url - The input URL to be encoded.
      Returns:
      the encoded websocket URL.
      See Also:
    • encodeNamespace

      public String encodeNamespace(String name)
      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 class ExternalContext
      Parameters:
      name - Name to be encoded
      Returns:
      the unique name prefixed with namespace.
      See Also:
    • dispatch

      public void dispatch(String requestURI) throws IOException, FacesException
      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 method getRequestDispatcher(path), and calling the forward() method on the resulting object.

      If the call to getRequestDisatcher(path) returns null, send aServletResponse SC_NOT_FOUND error code.

      Specified by:
      dispatch in class ExternalContext
      Parameters:
      requestURI - Context relative path to the specified resource, which must start with a slash ("/") character
      Throws:
      IOException - if an input/output error occurs
      FacesException - thrown if a ServletException occurs
      See Also:
    • redirect

      public void redirect(String requestURI) throws IOException
      Description copied from class: ExternalContext

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

      The implementation must determine if the request is an Ajax request by obtaining a PartialViewContext instance from the FacesContext and calling PartialViewContext.isAjaxRequest().

      Jakarta Servlet: For non Ajax requests, this must be accomplished by calling the jakarta.servlet.http.HttpServletResponse method sendRedirect().

      For Ajax requests, the implementation must:
      Specified by:
      redirect in class ExternalContext
      Parameters:
      requestURI - Absolute URL to which the client should be redirected
      Throws:
      IOException - if an input/output error occurs
      See Also:
    • log

      public void log(String message)
      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 or PortletContext) as the one used during a call to log() on the ExternalContext returned by the FacesContext during an actual request.

      Jakarta Servlet: This must be performed by calling the jakarta.servlet.ServletContext method log(String).

      Specified by:
      log in class ExternalContext
      Parameters:
      message - Message to be logged
      See Also:
    • log

      public void log(String message, Throwable throwable)
      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 or PortletContext) as the one used when calling log() on the ExternalContext returned by the FacesContext during an actual request.

      Jakarta Servlet: This must be performed by calling the jakarta.servlet.ServletContext method log(String,Throwable).

      Specified by:
      log in class ExternalContext
      Parameters:
      message - Message to be logged
      throwable - Exception to be logged
      See Also:
    • getAuthType

      public String 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, or FORM_AUTH.

      Jakarta Servlet: This must be the value returned by the jakarta.servlet.http.HttpServletRequest method getAuthType().

      Specified by:
      getAuthType in class ExternalContext
      Returns:
      the authentication type.
      See Also:
    • getMimeType

      public String getMimeType(String file)
      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 or PortletContext) as the one used when calling getMimeType() on the ExternalContext returned by the FacesContext during an actual request.

      Jakarta Servlet: This must be the value returned by the jakarta.servlet.ServletContext method getMimeType().

      Overrides:
      getMimeType in class ExternalContext
      Parameters:
      file - The file for which the mime type should be obtained.
      Returns:
      the MIME type of the file.
      See Also:
    • getRemoteUser

      public String 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 method getRemoteUser().

      Specified by:
      getRemoteUser in class ExternalContext
      Returns:
      the user name of the current request.
      See Also:
    • getUserPrincipal

      public Principal getUserPrincipal()
      Description copied from class: ExternalContext

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

      Jakarta Servlet: This must be the value returned by the jakarta.servlet.http.HttpServletRequest method getUserPrincipal().

      Specified by:
      getUserPrincipal in class ExternalContext
      Returns:
      the Principal object.
      See Also:
    • isUserInRole

      public boolean isUserInRole(String role)
      Description copied from class: ExternalContext

      Return true if the currently authenticated user is included in the specified role. Otherwise, return false.

      Jakarta Servlet: This must be the value returned by the jakarta.servlet.http.HttpServletRequest method isUserInRole(role).

      Specified by:
      isUserInRole in class ExternalContext
      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 method invalidate().

      The default implementation throws UnsupportedOperationException and is provided for the sole purpose of not breaking existing applications that extend this class.

      Overrides:
      invalidateSession in class ExternalContext
      See Also:
    • addResponseCookie

      public void addResponseCookie(String name, String value, Map<String,Object> properties)
      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 method addCookie(). The Cookie argument must be constructed by passing the name and value parameters. If the properties arugument is non-null and not empty, the Cookie 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 the Map.
      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 class ExternalContext
      Parameters:
      name - To be passed as the first argument to the Cookie constructor.
      value - To be passed as the second argument to the Cookie constructor.
      properties - A Map containg key/value pairs to be passed as arguments to the setter methods as described above.
      See Also:
    • getResponseOutputStream

      public OutputStream getResponseOutputStream() throws IOException
      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 method getOutputStream().

      The default implementation throws UnsupportedOperationException and is provided for the sole purpose of not breaking existing applications that extend this class.

      Overrides:
      getResponseOutputStream in class ExternalContext
      Returns:
      the OutputStream for the current response.
      Throws:
      IOException - any IO related exception.
      See Also:
    • getResponseOutputWriter

      public Writer getResponseOutputWriter() throws IOException
      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 class ExternalContext
      Returns:
      the Writer for the current response.
      Throws:
      IOException - any IO related exception.
      See Also:
    • getRequestScheme

      public String 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 method getScheme().

      The default implementation throws UnsupportedOperationException and is provided for the sole purpose of not breaking existing applications that extend this class.

      Overrides:
      getRequestScheme in class ExternalContext
      Returns:
      the name of the scheme.
      See Also:
    • getRequestServerName

      public String 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 method getServerName().

      The default implementation throws UnsupportedOperationException and is provided for the sole purpose of not breaking existing applications that extend this class.

      Overrides:
      getRequestServerName in class ExternalContext
      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 method getServerPort().

      The default implementation throws UnsupportedOperationException and is provided for the sole purpose of not breaking existing applications that extend this class.

      Overrides:
      getRequestServerPort in class ExternalContext
      Returns:
      the port number to which the request was sent.
      See Also:
    • setResponseContentType

      public void setResponseContentType(String contentType)
      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 underlying jakarta.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 class ExternalContext
      Parameters:
      contentType - The content type to be set as the contentType of the response.
      See Also:
    • setResponseHeader

      public void setResponseHeader(String name, String value)
      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 class ExternalContext
      Parameters:
      name - The name of the response header.
      value - The value of the response header.
      See Also:
    • addResponseHeader

      public void addResponseHeader(String name, String value)
      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 class ExternalContext
      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 class ExternalContext
      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 class ExternalContext
      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 class ExternalContext
      See Also:
    • responseSendError

      public void responseSendError(int statusCode, String message) throws IOException
      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 class ExternalContext
      Parameters:
      statusCode - an HTTP status code
      message - 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 class ExternalContext
      Parameters:
      statusCode - an HTTP status code
      See Also:
    • responseFlushBuffer

      public void responseFlushBuffer() throws IOException
      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 class ExternalContext
      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.

      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 class ExternalContext
      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 underlying jakarta.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 class ExternalContext
      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 class ExternalContext
      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 underlying jakarta.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 class ExternalContext
      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 underlying jakarta.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 class ExternalContext
      Returns:
      boolean
      See Also:
    • encodeBookmarkableURL

      public String encodeBookmarkableURL(String baseUrl, Map<String,List<String>> parameters)
      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 the ClientWindow.

      The default implementation throws UnsupportedOperationException and is provided for the sole purpose of not breaking existing applications that extend this class.

      Overrides:
      encodeBookmarkableURL in class ExternalContext
      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

      public String encodeRedirectURL(String baseUrl, Map<String,List<String>> parameters)
      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 the ClientWindow.

      Overrides:
      encodeRedirectURL in class ExternalContext
      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

      public String encodePartialActionURL(String url)
      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 the ClientWindow.

      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 class ExternalContext
      Parameters:
      url - The input URL to be encoded
      Returns:
      the encoded URL.
      See Also:
    • getFlash

      public Flash getFlash()
      Description copied from class: ExternalContext

      Return the threadsafe Flash for this application. The default implementation will throw UnsupportedOperationException. Compliant Jakarta Faces runtimes must provide an implementation of this method.

      Overrides:
      getFlash in class ExternalContext
      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 associated FacesContext.

      Specified by:
      release in class ExternalContext
    • getFallbackMimeType

      public String getFallbackMimeType(String file)