Class HttpServletResponseWrapper

  • All Implemented Interfaces:
    javax.servlet.http.HttpServletResponse, javax.servlet.ServletResponse

    public class HttpServletResponseWrapper
    extends javax.servlet.http.HttpServletResponseWrapper
    An HttpServletResponse wrapper.
    Version:
    Coherence 2.3
    Author:
    cp 2003.07.24
    • Field Summary

      • Fields inherited from interface javax.servlet.http.HttpServletResponse

        SC_ACCEPTED, SC_BAD_GATEWAY, SC_BAD_REQUEST, SC_CONFLICT, SC_CONTINUE, SC_CREATED, SC_EXPECTATION_FAILED, SC_FORBIDDEN, SC_FOUND, SC_GATEWAY_TIMEOUT, SC_GONE, SC_HTTP_VERSION_NOT_SUPPORTED, SC_INTERNAL_SERVER_ERROR, SC_LENGTH_REQUIRED, SC_METHOD_NOT_ALLOWED, SC_MOVED_PERMANENTLY, SC_MOVED_TEMPORARILY, SC_MULTIPLE_CHOICES, SC_NO_CONTENT, SC_NON_AUTHORITATIVE_INFORMATION, SC_NOT_ACCEPTABLE, SC_NOT_FOUND, SC_NOT_IMPLEMENTED, SC_NOT_MODIFIED, SC_OK, SC_PARTIAL_CONTENT, SC_PAYMENT_REQUIRED, SC_PRECONDITION_FAILED, SC_PROXY_AUTHENTICATION_REQUIRED, SC_REQUEST_ENTITY_TOO_LARGE, SC_REQUEST_TIMEOUT, SC_REQUEST_URI_TOO_LONG, SC_REQUESTED_RANGE_NOT_SATISFIABLE, SC_RESET_CONTENT, SC_SEE_OTHER, SC_SERVICE_UNAVAILABLE, SC_SWITCHING_PROTOCOLS, SC_TEMPORARY_REDIRECT, SC_UNAUTHORIZED, SC_UNSUPPORTED_MEDIA_TYPE, SC_USE_PROXY
    • Constructor Summary

      Constructors 
      Constructor Description
      HttpServletResponseWrapper​(SessionHelper helper, javax.servlet.http.HttpServletRequest req, javax.servlet.http.HttpServletResponse res)
      Construct an HttpServletResponseWrapper object to wrap an app server's response object.
    • Method Summary

      All Methods Instance Methods Concrete Methods Deprecated Methods 
      Modifier and Type Method Description
      String encodeRedirectUrl​(String sUrl)
      Deprecated.
      As of version 2.1, use encodeRedirectURL(String url) instead
      String encodeRedirectURL​(String sUrl)
      Encodes the specified URL for use in the sendRedirect method or, if encoding is not needed, returns the URL unchanged.
      String encodeUrl​(String sUrl)
      Deprecated.
      As of version 2.1, use encodeURL(String url) instead
      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.
      protected String getDescription()
      Returns a string representation of this object's attributes.
      javax.servlet.http.HttpServletRequest getHttpServletRequest()
      Get the wrapped HttpServletRequest.
      javax.servlet.http.HttpServletResponse getHttpServletResponse()
      Get the wrapped HttpServletResponse.
      SessionHelper getSessionHelper()
      Get the SessionHelper.
      String toString()
      Returns a string representation of the object.
      • Methods inherited from class javax.servlet.http.HttpServletResponseWrapper

        addCookie, addDateHeader, addHeader, addIntHeader, containsHeader, getHeader, getHeaderNames, getHeaders, getStatus, getTrailerFields, sendError, sendError, sendRedirect, setDateHeader, setHeader, setIntHeader, setStatus, setStatus, setTrailerFields
      • Methods inherited from class javax.servlet.ServletResponseWrapper

        flushBuffer, getBufferSize, getCharacterEncoding, getContentType, getLocale, getOutputStream, getResponse, getWriter, isCommitted, isWrapperFor, isWrapperFor, reset, resetBuffer, setBufferSize, setCharacterEncoding, setContentLength, setContentLengthLong, setContentType, setLocale, setResponse
      • Methods inherited from interface javax.servlet.ServletResponse

        flushBuffer, getBufferSize, getCharacterEncoding, getContentType, getLocale, getOutputStream, getWriter, isCommitted, reset, resetBuffer, setBufferSize, setCharacterEncoding, setContentLength, setContentLengthLong, setContentType, setLocale
    • Constructor Detail

      • HttpServletResponseWrapper

        public HttpServletResponseWrapper​(SessionHelper helper,
                                          javax.servlet.http.HttpServletRequest req,
                                          javax.servlet.http.HttpServletResponse res)
        Construct an HttpServletResponseWrapper object to wrap an app server's response object.
        Parameters:
        helper - the SessionHelper for this application
        req - the wrapped request object
        res - the app server's response object
    • Method Detail

      • encodeRedirectURL

        public String encodeRedirectURL​(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 seperate 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 javax.servlet.http.HttpServletResponse
        Overrides:
        encodeRedirectURL in class javax.servlet.http.HttpServletResponseWrapper
        Parameters:
        sUrl - the url to be encoded
        Returns:
        the encoded URL if encoding is needed; the unchanged URL otherwise
        See Also:
        HttpServletResponseWrapper.sendRedirect(String), encodeUrl(String)
      • encodeRedirectUrl

        public String encodeRedirectUrl​(String sUrl)
        Deprecated.
        As of version 2.1, use encodeRedirectURL(String url) instead
        Specified by:
        encodeRedirectUrl in interface javax.servlet.http.HttpServletResponse
        Overrides:
        encodeRedirectUrl in class javax.servlet.http.HttpServletResponseWrapper
        Parameters:
        sUrl - the url to be encoded
        Returns:
        the encoded URL if encoding is needed; the unchanged URL otherwise
      • encodeURL

        public 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. 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 javax.servlet.http.HttpServletResponse
        Overrides:
        encodeURL in class javax.servlet.http.HttpServletResponseWrapper
        Parameters:
        sUrl - the url to be encoded
        Returns:
        the encoded URL if encoding is needed; the unchanged URL otherwise
      • encodeUrl

        public String encodeUrl​(String sUrl)
        Deprecated.
        As of version 2.1, use encodeURL(String url) instead
        Specified by:
        encodeUrl in interface javax.servlet.http.HttpServletResponse
        Overrides:
        encodeUrl in class javax.servlet.http.HttpServletResponseWrapper
        Parameters:
        sUrl - the url to be encoded
        Returns:
        the encoded URL if encoding is needed; the unchanged URL otherwise
      • toString

        public String toString()
        Returns a string representation of the object.
        Overrides:
        toString in class Object
        Returns:
        a string representation of the object
      • getDescription

        protected String getDescription()
        Returns a string representation of this object's attributes.
        Returns:
        a string representation of this object's attributes
      • getSessionHelper

        public SessionHelper getSessionHelper()
        Get the SessionHelper.
        Returns:
        the SessionHelper for this app
      • getHttpServletRequest

        public javax.servlet.http.HttpServletRequest getHttpServletRequest()
        Get the wrapped HttpServletRequest.
        Returns:
        the wrapped HttpServletRequest
      • getHttpServletResponse

        public javax.servlet.http.HttpServletResponse getHttpServletResponse()
        Get the wrapped HttpServletResponse.
        Returns:
        the wrapped HttpServletResponse