Class RequestWebScope

    • Field Detail

      • m_aHttpRequest

        protected final jakarta.servlet.http.HttpServletRequest m_aHttpRequest
      • m_aHttpResponse

        protected final jakarta.servlet.http.HttpServletResponse m_aHttpResponse
    • Constructor Detail

      • RequestWebScope

        public RequestWebScope​(@Nonnull
                               jakarta.servlet.http.HttpServletRequest aHttpRequest,
                               @Nonnull
                               jakarta.servlet.http.HttpServletResponse aHttpResponse)
    • Method Detail

      • getCreationDateTime

        @Nonnull
        public final LocalDateTime getCreationDateTime()
        Specified by:
        getCreationDateTime in interface com.helger.datetime.domain.IHasCreationDateTime
        Specified by:
        getCreationDateTime in interface IWebScope
        Returns:
        The date and time when this web scope was created. Never null.
      • addSpecialRequestParams

        @OverrideOnDemand
        @Nonnull
        protected com.helger.commons.state.EChange addSpecialRequestParams()
        Callback method to add special parameters.
        Returns:
        EChange.CHANGED if some attributes were added, false if not. If special attributes were added, existing attributes are kept and will not be overwritten with HTTP servlet request parameters!
      • isForbiddenParamValueChar

        public static boolean isForbiddenParamValueChar​(char c)
        Check if the provided char is forbidden in a request value or not.
        Parameters:
        c - Char to check
        Returns:
        true if it is forbidden, false if not.
        Since:
        9.0.6
        See Also:
        getWithoutForbiddenChars(String)
      • getWithoutForbiddenChars

        @Nullable
        public static String getWithoutForbiddenChars​(@Nullable
                                                      String s)
        Remove all chars from the input that cannot be serialized as XML.
        Parameters:
        s - The source value. May be null.
        Returns:
        null if the source value is null.
        Since:
        9.0.4
        See Also:
        isForbiddenParamValueChar(char)
      • initScope

        public final void initScope()
        Specified by:
        initScope in interface com.helger.scope.IScope
      • postDestroy

        protected void postDestroy()
        Overrides:
        postDestroy in class com.helger.scope.AbstractScope
      • headers

        @Nonnull
        public final com.helger.commons.http.HttpHeaderMap headers()
        Specified by:
        headers in interface IRequestWebScopeWithoutResponse
        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.
      • isFileBasedRequest

        public static boolean isFileBasedRequest​(@Nonnull
                                                 String sServletPath)
        This is a heuristic method to determine whether a request is for a file (e.g. x.jsp) or for a servlet. This method return true if the last dot is after the last slash
        Parameters:
        sServletPath - The non-null servlet path to check
        Returns:
        true if it is assumed that the request is file based, false if it can be assumed to be a regular servlet.
      • getContextPath

        @Nonnull
        public String getContextPath()
        Specified by:
        getContextPath in interface IRequestWebScopeWithoutResponse
        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:
        IRequestWebScopeWithoutResponse.getFullContextPath()
      • getResponse

        @Nonnull
        public final jakarta.servlet.http.HttpServletResponse getResponse()
        Specified by:
        getResponse in interface IRequestWebScope
        Returns:
        The underlying HTTP servlet response object
      • encodeURL

        @Nonnull
        public String encodeURL​(@Nonnull
                                String sURL)
        Description copied from interface: IRequestWebScopeWithoutResponse
        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.

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

        @Nonnull
        public String encodeRedirectURL​(@Nonnull
                                        String sURL)
        Description copied from interface: IRequestWebScopeWithoutResponse
        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.

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

        public boolean equals​(Object o)
        Overrides:
        equals in class com.helger.scope.AbstractScope
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class com.helger.scope.AbstractScope
      • toString

        public String toString()
        Overrides:
        toString in class com.helger.scope.AbstractScope