Interface IRequestWebScopeWithoutResponse

  • All Superinterfaces:
    com.helger.datetime.domain.IHasCreationDateTime, com.helger.commons.id.IHasID<String>, com.helger.scope.IRequestScope, com.helger.scope.IScope, IWebScope
    All Known Subinterfaces:
    IRequestWebScope
    All Known Implementing Classes:
    RequestWebScope, RequestWebScopeMultipart

    public interface IRequestWebScopeWithoutResponse
    extends com.helger.scope.IRequestScope, IWebScope
    Interface for a single web request scope object that does not offer access to the HTTP response.
    Author:
    Philip Helger
    • Method Summary

      All Methods Instance Methods Abstract Methods Default Methods 
      Modifier and Type Method Description
      default boolean areCookiesEnabled()
      Check if this request uses a Cookie based session handling (meaning cookies are enabled) or whether the session ID needs to be appended to a URL.
      default com.helger.commons.url.ISimpleURL encodeRedirectURL​(com.helger.commons.url.ISimpleURL aURL)
      Encodes the specified URL for use in the sendRedirect method or, if encoding is not needed, returns the URL unchanged.
      String encodeRedirectURL​(String sURL)
      Encodes the specified URL for use in the sendRedirect method or, if encoding is not needed, returns the URL unchanged.
      default com.helger.commons.url.ISimpleURL encodeURL​(com.helger.commons.url.ISimpleURL aURL)
      Encodes the specified URL by including the session ID in it, or, if encoding is not needed, returns the URL unchanged.
      String encodeURL​(String sURL)
      Encodes the specified URL by including the session ID in it, or, if encoding is not needed, returns the URL unchanged.
      default String getAuthType()
      Returns the name of the authentication scheme used to protect the servlet.
      default com.helger.useragent.browser.BrowserInfo getBrowserInfo()  
      default String getCharacterEncoding()
      Returns the name of the character encoding used in the body of this request.
      default Charset getCharset()  
      default long getContentLength()
      Returns the length, in bytes, of the request body and made available by the input stream, or -1 if the length is not known.
      default String getContentType()
      Returns the MIME type of the body of the request, or null if the type is not known.
      String getContextAndServletPath()  
      String getContextPath()  
      default jakarta.servlet.http.Cookie[] getCookies()
      Returns an array containing all of the Cookie objects the client sent with this request.
      String getFullContextAndServletPath()  
      default String getFullContextPath()  
      default String getFullServerPath()  
      default com.helger.commons.http.EHttpMethod getHttpMethod()  
      default com.helger.http.EHttpVersion getHttpVersion()  
      default String getLocalAddr()
      Returns the Internet Protocol (IP) address of the interface on which the request was received.
      default String getLocalName()
      Returns the host name of the Internet Protocol (IP) interface on which the request was received.
      default int getLocalPort()
      Returns the Internet Protocol (IP) port number of the interface on which the request was received.
      default String getMethod()
      Returns the name of the HTTP method with which this request was made, for example, GET, POST, or PUT.
      default String getPathInfo()
      Returns any extra path information associated with the URL the client sent when it made this request.
      default String getPathTranslated()
      Returns any extra path information after the servlet name but before the query string, and translates it to a real path.
      default String getPathWithinServlet()
      Return the path within the servlet mapping for the given request, i.e. the part of the request's URL beyond the part that called the servlet, or "" if the whole URL has been used to identify the servlet.
      default String getPathWithinServletContext()
      Return the URI of the request within the servlet context.
      default String getProtocol()
      Returns the name and version of the protocol the request uses in the form protocol/majorVersion.minorVersion, for example, HTTP/1.1.
      default String getQueryString()
      Returns the query string that is contained in the request URL after the path.
      default String getRemoteAddr()
      Returns the Internet Protocol (IP) address of the client or last proxy that sent the request.
      default String getRemoteHost()
      Returns the fully qualified name of the client or the last proxy that sent the request.
      default int getRemotePort()
      Returns the Internet Protocol (IP) source port of the client or last proxy that sent the request.
      default String getRemoteUser()
      Returns the login of the user making this request, if the user has been authenticated, or null if the user has not been authenticated.
      jakarta.servlet.http.HttpServletRequest getRequest()  
      com.helger.servlet.request.IRequestParamMap getRequestParamMap()  
      default String getRequestURIDecoded()
      Get the request URI without an eventually appended session (";jsessionid=...").
      This method considers the GlobalWebScope custom context path.
      This method returns the percent decoded parameters Examples of Returned Values First line of HTTP request Returned Value POST /some/pa%3Ath.html;JSESSIONID=4711 /some/pa:th.html GET http://foo.bar/a.html;JSESSIONID=4711 /a.html HEAD /xyz;JSESSIONID=4711?
      default String getRequestURIEncoded()
      Get the request URI without an eventually appended session (";jsessionid=...").
      This method considers the GlobalWebScope custom context path.
      This method returns the percent encoded parameters "as is" Examples of Returned Values First line of HTTP request Returned Value POST /some/pa%3Ath.html;JSESSIONID=4711 /some/pa%3Ath.html GET http://foo.bar/a.html;JSESSIONID=4711 /a.html HEAD /xyz;JSESSIONID=4711?
      default StringBuilder getRequestURLDecoded()
      Reconstructs the URL the client used to make the request.
      default StringBuilder getRequestURLEncoded()
      Reconstructs the URL the client used to make the request.
      default String getScheme()
      Returns the name of the scheme used to make this request, for example, http, https, or ftp.
      default String getServerName()
      Returns the host name of the server to which the request was sent.
      default int getServerPort()
      Returns the port number to which the request was sent.
      default String getServletPath()
      Returns the part of this request's URL that calls the servlet.
      default jakarta.servlet.http.HttpSession getSession​(boolean bCreateIfNotExisting)
      Returns the current HttpSession associated with this request or, if there is no current session and create is true, returns a new session.
      default String getSessionID​(boolean bCreateIfNotExisting)  
      default String getURIDecoded()
      Get the full URI (excl. protocol and host) and parameters of the current request.
      default String getURIEncoded()
      Get the full URI (excl. protocol and host) and parameters of the current request.
      default String getURLDecoded()
      Get the full URL (incl. protocol) and parameters of the current request.
      default String getURLEncoded()
      Get the full URL (incl. protocol) and parameters of the current request.
      default com.helger.useragent.IUserAgent getUserAgent()
      Get the user agent object of this HTTP request.
      default Principal getUserPrincipal()
      Returns a java.security.Principal object containing the name of the current authenticated user.
      com.helger.commons.http.HttpHeaderMap headers()  
      default boolean isRequestedSessionIdFromCookie()
      Checks whether the requested session ID came in as a cookie.
      default boolean isRequestedSessionIdFromURL()
      Checks whether the requested session ID came in as part of the request URL.
      default boolean isRequestedSessionIdValid()
      Checks whether the requested session ID is still valid.
      default boolean isSecure()
      Returns a boolean indicating whether this request was made using a secure channel, such as HTTPS.
      default boolean isUserInRole​(String sRole)
      Returns a boolean indicating whether the authenticated user is included in the specified logical "role".
      IRequestParamContainer params()  
      • Methods inherited from interface com.helger.datetime.domain.IHasCreationDateTime

        getCreationDate, getCreationTime, hasCreationDateTime, isCreatedAt
      • Methods inherited from interface com.helger.scope.IRequestScope

        getSessionID
      • Methods inherited from interface com.helger.scope.IScope

        attrs, destroyScope, getAllScopeRenewalAwareAttributes, getID, initScope, isDestroyed, isInDestruction, isValid, runAtomic, runAtomic
    • Method Detail

      • headers

        @Nonnull
        @ReturnsMutableObject
        com.helger.commons.http.HttpHeaderMap headers()
        Returns:
        A cached header map for this request. Never null. Alterations to this map are visible everywhere. Clone the object if you need to modify it.
      • getUserAgent

        @Nonnull
        default com.helger.useragent.IUserAgent getUserAgent()
        Get the user agent object of this HTTP request.
        Returns:
        A non-null user agent object.
      • getBrowserInfo

        @Nullable
        default com.helger.useragent.browser.BrowserInfo getBrowserInfo()
        Returns:
        The information about the matching browser or null if no known browser was detected.
      • getRequestParamMap

        @Nonnull
        com.helger.servlet.request.IRequestParamMap getRequestParamMap()
        Returns:
        A cached request param map for this request. Never null.
      • getSessionID

        @Nullable
        default String getSessionID​(boolean bCreateIfNotExisting)
        Specified by:
        getSessionID in interface com.helger.scope.IRequestScope
      • getCharacterEncoding

        @Nullable
        default String getCharacterEncoding()
        Returns the name of the character encoding used in the body of this request. This method returns null if the request does not specify a character encoding
        Returns:
        a String containing the name of the character encoding, or null if the request does not specify a character encoding
      • getContentType

        @Nullable
        default String getContentType()
        Returns the MIME type of the body of the request, or null if the type is not known. For HTTP servlets, same as the value of the CGI variable CONTENT_TYPE.
        Returns:
        a String containing the name of the MIME type of the request, or null if the type is not known
      • getContentLength

        @CheckForSigned
        default long getContentLength()
        Returns the length, in bytes, of the request body and made available by the input stream, or -1 if the length is not known. For HTTP servlets, same as the value of the CGI variable CONTENT_LENGTH.
        Returns:
        an integer containing the length of the request body or -1 if the length is not known
      • getCharset

        @Nullable
        default Charset getCharset()
        Returns:
        The charset defined for this request. May be null if none is present;
      • getProtocol

        default String getProtocol()
        Returns the name and version of the protocol the request uses in the form protocol/majorVersion.minorVersion, for example, HTTP/1.1. For HTTP servlets, the value returned is the same as the value of the CGI variable SERVER_PROTOCOL.
        Returns:
        a String containing the protocol name and version number
      • getHttpVersion

        @Nullable
        default com.helger.http.EHttpVersion getHttpVersion()
        Returns:
        The EHttpVersion of the request.
      • getScheme

        default String getScheme()
        Returns the name of the scheme used to make this request, for example, http, https, or ftp. Different schemes have different rules for constructing URLs, as noted in RFC 1738.
        Returns:
        a String containing the name of the scheme used to make this request
      • getServerName

        default String getServerName()
        Returns the host name of the server to which the request was sent. It is the value of the part before ":" in the Host header value, if any, or the resolved server name, or the server IP address.
        Returns:
        a String containing the name of the server
      • getServerPort

        default int getServerPort()
        Returns the port number to which the request was sent. It is the value of the part after ":" in the Host header value, if any, or the server port where the client connection was accepted on.
        Returns:
        an integer specifying the port number
      • getRemoteAddr

        default String getRemoteAddr()
        Returns the Internet Protocol (IP) address of the client or last proxy that sent the request. For HTTP servlets, same as the value of the CGI variable REMOTE_ADDR.
        Returns:
        a String containing the IP address of the client that sent the request
      • getRemoteHost

        default String getRemoteHost()
        Returns the fully qualified name of the client or the last proxy that sent the request. If the engine cannot or chooses not to resolve the hostname (to improve performance), this method returns the dotted-string form of the IP address. For HTTP servlets, same as the value of the CGI variable REMOTE_HOST.
        Returns:
        a String containing the fully qualified name of the client
      • getRemotePort

        default int getRemotePort()
        Returns the Internet Protocol (IP) source port of the client or last proxy that sent the request.
        Returns:
        an integer specifying the port number
      • isSecure

        default boolean isSecure()
        Returns a boolean indicating whether this request was made using a secure channel, such as HTTPS.
        Returns:
        a boolean indicating if the request was made using a secure channel
      • getLocalName

        default String getLocalName()
        Returns the host name of the Internet Protocol (IP) interface on which the request was received.
        Returns:
        a String containing the host name of the IP on which the request was received.
      • getLocalAddr

        default String getLocalAddr()
        Returns the Internet Protocol (IP) address of the interface on which the request was received.
        Returns:
        a String containing the IP address on which the request was received.
      • getLocalPort

        default int getLocalPort()
        Returns the Internet Protocol (IP) port number of the interface on which the request was received.
        Returns:
        an integer specifying the port number
      • getAuthType

        default String getAuthType()
        Returns the name of the authentication scheme used to protect the servlet. All servlet containers support basic, form and client certificate authentication, and may additionally support digest authentication. If the servlet is not authenticated null is returned.

        Same as the value of the CGI variable AUTH_TYPE.

        Returns:
        one of the static members BASIC_AUTH, FORM_AUTH, CLIENT_CERT_AUTH, DIGEST_AUTH (suitable for == comparison) or the container-specific string indicating the authentication scheme, or null if the request was not authenticated.
      • getCookies

        @Nullable
        default jakarta.servlet.http.Cookie[] getCookies()
        Returns an array containing all of the Cookie objects the client sent with this request. This method returns null if no cookies were sent.
        Returns:
        an array of all the Cookies included with this request, or null if the request has no cookies
      • getMethod

        default String getMethod()
        Returns the name of the HTTP method with which this request was made, for example, GET, POST, or PUT. Same as the value of the CGI variable REQUEST_METHOD.
        Returns:
        a String specifying the name of the method with which this request was made
      • getHttpMethod

        @Nullable
        default com.helger.commons.http.EHttpMethod getHttpMethod()
        Returns:
        The EHttpMethod matching the getMethod()
      • getPathInfo

        default String getPathInfo()
        Returns any extra path information associated with the URL the client sent when it made this request. The extra path information follows the servlet path but precedes the query string and will start with a "/" character.

        This method returns null if there was no extra path information.

        Same as the value of the CGI variable PATH_INFO.

        Returns:
        a String, decoded by the web container, specifying extra path information that comes after the servlet path but before the query string in the request URL; or null if the URL does not have any extra path information
      • getPathTranslated

        default String getPathTranslated()
        Returns any extra path information after the servlet name but before the query string, and translates it to a real path. Same as the value of the CGI variable PATH_TRANSLATED.

        If the URL does not have any extra path information, this method returns null or the servlet container cannot translate the virtual path to a real path for any reason (such as when the web application is executed from an archive). The web container does not decode this string.

        Returns:
        a String specifying the real path, or null if the URL does not have any extra path information
      • getContextPath

        @Nonnull
        String getContextPath()
        Returns:
        Returns the portion of the request URI that indicates the context of the request. The context path always comes first in a request URI. The path starts with a "/" character but does not end with a "/" character. For servlets in the default (root) context, this method returns "". The container does not decode this string. E.g. /context or an empty string for the root context. Never with a trailing slash.
        See Also:
        getFullContextPath()
      • getQueryString

        default String getQueryString()
        Returns the query string that is contained in the request URL after the path. This method returns null if the URL does not have a query string. Same as the value of the CGI variable QUERY_STRING.
        Returns:
        a String containing the query string or null if the URL contains no query string. The value is not decoded by the container.
      • getRemoteUser

        default String getRemoteUser()
        Returns the login of the user making this request, if the user has been authenticated, or null if the user has not been authenticated. Whether the user name is sent with each subsequent request depends on the browser and type of authentication. Same as the value of the CGI variable REMOTE_USER.
        Returns:
        a String specifying the login of the user making this request, or null if the user login is not known
      • isUserInRole

        default boolean isUserInRole​(String sRole)
        Returns a boolean indicating whether the authenticated user is included in the specified logical "role". Roles and role membership can be defined using deployment descriptors. If the user has not been authenticated, the method returns false.
        Parameters:
        sRole - a String specifying the name of the role
        Returns:
        a boolean indicating whether the user making this request belongs to a given role; false if the user has not been authenticated
      • getUserPrincipal

        @Nullable
        default Principal getUserPrincipal()
        Returns a java.security.Principal object containing the name of the current authenticated user. If the user has not been authenticated, the method returns null.
        Returns:
        a java.security.Principal containing the name of the user making this request; null if the user has not been authenticated
      • getRequestURIDecoded

        @Nonnull
        default String getRequestURIDecoded()
        Get the request URI without an eventually appended session (";jsessionid=...").
        This method considers the GlobalWebScope custom context path.
        This method returns the percent decoded parameters
        Examples of Returned Values
        First line of HTTP request Returned Value
        POST /some/pa%3Ath.html;JSESSIONID=4711 /some/pa:th.html
        GET http://foo.bar/a.html;JSESSIONID=4711 /a.html
        HEAD /xyz;JSESSIONID=4711?a=b /xyz
        Returns:
        The request URI without the optional session ID. Never null.
        Since:
        9.1.0
      • getRequestURIEncoded

        @Nonnull
        default String getRequestURIEncoded()
        Get the request URI without an eventually appended session (";jsessionid=...").
        This method considers the GlobalWebScope custom context path.
        This method returns the percent encoded parameters "as is"
        Examples of Returned Values
        First line of HTTP request Returned Value
        POST /some/pa%3Ath.html;JSESSIONID=4711 /some/pa%3Ath.html
        GET http://foo.bar/a.html;JSESSIONID=4711 /a.html
        HEAD /xyz;JSESSIONID=4711?a=b /xyz
        Returns:
        The request URI without the optional session ID. Never null.
        Since:
        9.1.0
      • getRequestURLDecoded

        @Nonnull
        @Nonempty
        default StringBuilder getRequestURLDecoded()
        Reconstructs the URL the client used to make the request. The returned URL contains a protocol, server name, port number, and server path, but it does not include query string parameters.
        This method returns the percent decoded parameters

        If this request has been forwarded using RequestDispatcher.forward(jakarta.servlet.ServletRequest, jakarta.servlet.ServletResponse), the server path in the reconstructed URL must reflect the path used to obtain the RequestDispatcher, and not the server path specified by the client.

        Because this method returns a StringBuilder, not a string, you can modify the URL easily, for example, to append query parameters.

        This method is useful for creating redirect messages and for reporting errors.

        Returns:
        a StringBuilder object containing the reconstructed URL
        Since:
        9.1.10
      • getRequestURLEncoded

        @Nonnull
        @Nonempty
        default StringBuilder getRequestURLEncoded()
        Reconstructs the URL the client used to make the request. The returned URL contains a protocol, server name, port number, and server path, but it does not include query string parameters.
        This method returns the percent encoded parameters "as is"

        If this request has been forwarded using RequestDispatcher.forward(jakarta.servlet.ServletRequest, jakarta.servlet.ServletResponse), the server path in the reconstructed URL must reflect the path used to obtain the RequestDispatcher, and not the server path specified by the client.

        Because this method returns a StringBuilder, not a string, you can modify the URL easily, for example, to append query parameters.

        This method is useful for creating redirect messages and for reporting errors.

        Returns:
        a StringBuilder object containing the reconstructed URL
        Since:
        9.1.10
      • getServletPath

        @Nonnull
        default String getServletPath()
        Returns the part of this request's URL that calls the servlet. This path starts with a "/" character and includes either the servlet name or a path to the servlet, but does not include any extra path information or a query string. Same as the value of the CGI variable SCRIPT_NAME.

        This method will return an empty string ("") if the servlet used to process this request was matched using the "/*" pattern.

        Returns:
        a String containing the name or path of the servlet being called, as specified in the request URL, decoded, or an empty string if the servlet used to process the request is matched using the "/*" pattern.
      • getSession

        @Nullable
        default jakarta.servlet.http.HttpSession getSession​(boolean bCreateIfNotExisting)
        Returns the current HttpSession associated with this request or, if there is no current session and create is true, returns a new session.

        If bCreateIfNotExisting is false and the request has no valid HttpSession, this method returns null.

        To make sure the session is properly maintained, you must call this method before the response is committed. If the container is using cookies to maintain session integrity and is asked to create a new session when the response is committed, an IllegalStateException is thrown.

        Parameters:
        bCreateIfNotExisting - true to create a new session for this request if necessary; false to return null if there's no current session
        Returns:
        the HttpSession associated with this request or null if bCreateIfNotExisting is false and the request has no valid session
      • isRequestedSessionIdValid

        default boolean isRequestedSessionIdValid()
        Checks whether the requested session ID is still valid.

        If the client did not specify any session ID, this method returns false.

        Returns:
        true if this request has an id for a valid session in the current session context; false otherwise
        See Also:
        getSession(boolean)
      • isRequestedSessionIdFromCookie

        default boolean isRequestedSessionIdFromCookie()
        Checks whether the requested session ID came in as a cookie.
        Returns:
        true if the session ID came in as a cookie; otherwise, false
        See Also:
        getSession(boolean)
      • isRequestedSessionIdFromURL

        default boolean isRequestedSessionIdFromURL()
        Checks whether the requested session ID came in as part of the request URL.
        Returns:
        true if the session ID came in as part of a URL; otherwise, false
        See Also:
        getSession(boolean)
      • getFullServerPath

        @Nonnull
        default String getFullServerPath()
        Returns:
        Return the absolute server path. E.g. "http://localhost:8080"
      • getFullContextPath

        @Nonnull
        default String getFullContextPath()
        Returns:
        Return the absolute context path. E.g. http://localhost:8080/context. Never with a trailing slash.
        See Also:
        getContextPath()
      • getContextAndServletPath

        @Nonnull
        String getContextAndServletPath()
        Returns:
        Return the absolute servlet path. E.g. /context/config.jsp or /context/action/
      • getFullContextAndServletPath

        @Nonnull
        String getFullContextAndServletPath()
        Returns:
        Return the absolute servlet path. E.g. http://localhost:8080/context/config.jsp or http://localhost:8080/context/action/
      • getURIDecoded

        @Nonnull
        @Nonempty
        default String getURIDecoded()
        Get the full URI (excl. protocol and host) and parameters of the current request.
        /context/servlet/path/a/b?c=123&d=789
        Returns:
        The full URI of the current request.
        Since:
        9.1.10
      • getURIEncoded

        @Nonnull
        @Nonempty
        default String getURIEncoded()
        Get the full URI (excl. protocol and host) and parameters of the current request.
        /context/servlet/path/a/b?c=123&d=789
        Returns:
        The full URI of the current request.
        Since:
        9.1.10
      • getURLDecoded

        @Nonnull
        @Nonempty
        default String getURLDecoded()
        Get the full URL (incl. protocol) and parameters of the current request.
        http://hostname.com:81/context/servlet/path/a/b?c=123&d=789
        Returns:
        The full URL of the current request.
        Since:
        9.1.10
      • getURLEncoded

        @Nonnull
        @Nonempty
        default String getURLEncoded()
        Get the full URL (incl. protocol) and parameters of the current request.
        http://hostname.com:81/context/servlet/path/a/b?c=123&d=789
        Returns:
        The full URL of the current request.
        Since:
        9.1.10
      • encodeURL

        @Nonnull
        String encodeURL​(@Nonnull
                         String sURL)
        Encodes the specified URL by including the session ID in it, or, if encoding is not needed, returns the URL unchanged. The implementation of this method includes the logic to determine whether the session ID needs to be encoded in the URL. For example, if the browser supports cookies, or session tracking is turned off, URL encoding is unnecessary.

        For robust session tracking, all URLs emitted by a servlet should be run through this method. Otherwise, URL rewriting cannot be used with browsers which do not support cookies.

        Parameters:
        sURL - the url to be encoded. May not be null.
        Returns:
        the encoded URL if encoding is needed; the unchanged URL otherwise.
      • encodeURL

        @Nonnull
        default com.helger.commons.url.ISimpleURL encodeURL​(@Nonnull
                                                            com.helger.commons.url.ISimpleURL aURL)
        Encodes the specified URL by including the session ID in it, or, if encoding is not needed, returns the URL unchanged. The implementation of this method includes the logic to determine whether the session ID needs to be encoded in the URL. For example, if the browser supports cookies, or session tracking is turned off, URL encoding is unnecessary.

        For robust session tracking, all URLs emitted by a servlet should be run through this method. Otherwise, URL rewriting cannot be used with browsers which do not support cookies.

        Parameters:
        aURL - the url to be encoded. May not be null.
        Returns:
        the encoded URL if encoding is needed. Never null.
      • encodeRedirectURL

        @Nonnull
        String encodeRedirectURL​(@Nonnull
                                 String sURL)
        Encodes the specified URL for use in the sendRedirect method or, if encoding is not needed, returns the URL unchanged. The implementation of this method includes the logic to determine whether the session ID needs to be encoded in the URL. Because the rules for making this determination can differ from those used to decide whether to encode a normal link, this method is separated from the encodeURL method.

        All URLs sent to the HttpServletResponse.sendRedirect method should be run through this method. Otherwise, URL rewriting cannot be used with browsers which do not support cookies.

        Parameters:
        sURL - the url to be encoded.
        Returns:
        the encoded URL if encoding is needed; the unchanged URL otherwise.
        See Also:
        encodeURL(String)
      • encodeRedirectURL

        @Nonnull
        default com.helger.commons.url.ISimpleURL encodeRedirectURL​(@Nonnull
                                                                    com.helger.commons.url.ISimpleURL aURL)
        Encodes the specified URL for use in the sendRedirect method or, if encoding is not needed, returns the URL unchanged. The implementation of this method includes the logic to determine whether the session ID needs to be encoded in the URL. Because the rules for making this determination can differ from those used to decide whether to encode a normal link, this method is separated from the encodeURL method.

        All URLs sent to the HttpServletResponse.sendRedirect method should be run through this method. Otherwise, URL rewriting cannot be used with browsers which do not support cookies.

        Parameters:
        aURL - the url to be encoded. May not be null.
        Returns:
        the encoded URL if encoding is needed. Never null.
        See Also:
        encodeURL(String)
      • areCookiesEnabled

        default boolean areCookiesEnabled()
        Check if this request uses a Cookie based session handling (meaning cookies are enabled) or whether the session ID needs to be appended to a URL.
        Returns:
        true if the session ID is passed via cookies.
      • getPathWithinServletContext

        @Nonnull
        default String getPathWithinServletContext()
        Return the URI of the request within the servlet context.
        Returns:
        the path within the web application and never null. By default "/" is returned is an empty request URI is determined.
      • getPathWithinServlet

        @Nonnull
        default String getPathWithinServlet()
        Return the path within the servlet mapping for the given request, i.e. the part of the request's URL beyond the part that called the servlet, or "" if the whole URL has been used to identify the servlet.
        Detects include request URL if called within a RequestDispatcher include.
        E.g.: servlet mapping = "/test/*"; request URI = "/test/a" -> "/a".
        E.g.: servlet mapping = "/test"; request URI = "/test" -> "".
        E.g.: servlet mapping = "/*.test"; request URI = "/a.test" -> "".
        Returns:
        the path within the servlet mapping, or ""
      • getRequest

        @Nonnull
        jakarta.servlet.http.HttpServletRequest getRequest()
        Returns:
        The underlying HTTP servlet request object. Never null .