com.ibm.websphere.servlet.response

Class StoredResponse

  • java.lang.Object
    • javax.servlet.ServletResponseWrapper
      • javax.servlet.http.HttpServletResponseWrapper
        • com.ibm.websphere.servlet.response.StoredResponse
  • All Implemented Interfaces:
    StoredResponseCompat, com.ibm.wsspi.webcontainer.servlet.IExtendedResponse, com.ibm.wsspi.webcontainer.util.IOutputStreamObserver, com.ibm.wsspi.webcontainer.util.IResponseOutput, java.io.Serializable, javax.servlet.http.HttpServletResponse, javax.servlet.ServletResponse
    Direct Known Subclasses:
    ChainedResponse


    public class StoredResponse
    extends javax.servlet.http.HttpServletResponseWrapper
    implements StoredResponseCompat, javax.servlet.http.HttpServletResponse, java.io.Serializable, com.ibm.wsspi.webcontainer.util.IResponseOutput, com.ibm.wsspi.webcontainer.servlet.IExtendedResponse, com.ibm.wsspi.webcontainer.util.IOutputStreamObserver
    StoredResponse is a response object that can be instantiated by any servlet and used/passed as a standard HttpResponse. The data that is written to this response will be stored for later use.
    See Also:
    Serialized Form
    • Field Summary

      Fields 
      Modifier and Type Field and Description
      protected com.ibm.wsspi.webcontainer.util.ByteBufferOutputStream _bbOut 
      protected com.ibm.ws.webcontainer.srt.SRTOutputStream _out 
      protected boolean _outputStreamObtained 
      protected java.io.PrintWriter _writer 
      protected boolean _writerObtained 
      protected int bufferSize 
      protected static java.util.logging.Logger logger 
      protected static com.ibm.ejs.ras.TraceNLS nls 
      protected boolean outputWritten 
      • 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 and Description
      StoredResponse() 
      StoredResponse(boolean isInclude) 
      StoredResponse(com.ibm.wsspi.webcontainer.servlet.IExtendedResponse extResponse, boolean isInclude) 
    • Field Detail

      • logger

        protected static java.util.logging.Logger logger
      • nls

        protected static final com.ibm.ejs.ras.TraceNLS nls
      • _writer

        protected java.io.PrintWriter _writer
      • _out

        protected com.ibm.ws.webcontainer.srt.SRTOutputStream _out
      • _bbOut

        protected com.ibm.wsspi.webcontainer.util.ByteBufferOutputStream _bbOut
      • _writerObtained

        protected boolean _writerObtained
      • _outputStreamObtained

        protected boolean _outputStreamObtained
      • bufferSize

        protected int bufferSize
      • outputWritten

        protected boolean outputWritten
    • Constructor Detail

      • StoredResponse

        public StoredResponse()
      • StoredResponse

        public StoredResponse(boolean isInclude)
      • StoredResponse

        public StoredResponse(com.ibm.wsspi.webcontainer.servlet.IExtendedResponse extResponse,
                      boolean isInclude)
    • Method Detail

      • writerObtained

        public boolean writerObtained()
        Specified by:
        writerObtained in interface com.ibm.wsspi.webcontainer.util.IResponseOutput
      • outputStreamObtained

        public boolean outputStreamObtained()
        Specified by:
        outputStreamObtained in interface com.ibm.wsspi.webcontainer.util.IResponseOutput
      • addCookie

        public void addCookie(javax.servlet.http.Cookie cookie)
        Specified by:
        addCookie in interface javax.servlet.http.HttpServletResponse
        Overrides:
        addCookie in class javax.servlet.http.HttpServletResponseWrapper
      • getIResponse

        public IResponse getIResponse()
        Specified by:
        getIResponse in interface com.ibm.wsspi.webcontainer.servlet.IExtendedResponse
      • getOutputStream

        public javax.servlet.ServletOutputStream getOutputStream()
                                                          throws java.lang.IllegalStateException,
                                                                 java.io.IOException
        Specified by:
        getOutputStream in interface javax.servlet.ServletResponse
        Overrides:
        getOutputStream in class javax.servlet.ServletResponseWrapper
        Throws:
        java.lang.IllegalStateException
        java.io.IOException
      • setContentLength

        public void setContentLength(int len)
        Specified by:
        setContentLength in interface javax.servlet.ServletResponse
        Overrides:
        setContentLength in class javax.servlet.ServletResponseWrapper
      • setContentType

        public void setContentType(java.lang.String type)
        Specified by:
        setContentType in interface javax.servlet.ServletResponse
        Overrides:
        setContentType in class javax.servlet.ServletResponseWrapper
      • setBufferSize

        public void setBufferSize(int size)
                           throws java.lang.IllegalStateException
        Specified by:
        setBufferSize in interface javax.servlet.ServletResponse
        Overrides:
        setBufferSize in class javax.servlet.ServletResponseWrapper
        Throws:
        java.lang.IllegalStateException
      • getBufferSize

        public int getBufferSize()
        Specified by:
        getBufferSize in interface javax.servlet.ServletResponse
        Overrides:
        getBufferSize in class javax.servlet.ServletResponseWrapper
      • flushBuffer

        public void flushBuffer()
                         throws java.io.IOException
        Specified by:
        flushBuffer in interface javax.servlet.ServletResponse
        Overrides:
        flushBuffer in class javax.servlet.ServletResponseWrapper
        Throws:
        java.io.IOException
      • flushBuffer

        public void flushBuffer(boolean flushToWire)
                         throws java.io.IOException
        Specified by:
        flushBuffer in interface com.ibm.wsspi.webcontainer.util.IResponseOutput
        Throws:
        java.io.IOException
      • isCommitted

        public boolean isCommitted()
        Specified by:
        isCommitted in interface com.ibm.wsspi.webcontainer.util.IResponseOutput
        Specified by:
        isCommitted in interface javax.servlet.ServletResponse
        Overrides:
        isCommitted in class javax.servlet.ServletResponseWrapper
      • reset

        public void reset()
                   throws java.lang.IllegalStateException
        Specified by:
        reset in interface com.ibm.wsspi.webcontainer.util.IResponseOutput
        Specified by:
        reset in interface javax.servlet.ServletResponse
        Overrides:
        reset in class javax.servlet.ServletResponseWrapper
        Throws:
        java.lang.IllegalStateException
      • getHeaderTable

        public java.util.Vector[] getHeaderTable()
        Specified by:
        getHeaderTable in interface com.ibm.wsspi.webcontainer.servlet.IExtendedResponse
      • addSessionCookie

        public void addSessionCookie(javax.servlet.http.Cookie cookie)
        Specified by:
        addSessionCookie in interface com.ibm.wsspi.webcontainer.servlet.IExtendedResponse
      • setLocale

        public void setLocale(java.util.Locale loc)
        Specified by:
        setLocale in interface javax.servlet.ServletResponse
        Overrides:
        setLocale in class javax.servlet.ServletResponseWrapper
      • setCharacterEncoding

        public void setCharacterEncoding(java.lang.String encoding)
        Specified by:
        setCharacterEncoding in interface javax.servlet.ServletResponse
        Overrides:
        setCharacterEncoding in class javax.servlet.ServletResponseWrapper
      • getLocale

        public java.util.Locale getLocale()
        Specified by:
        getLocale in interface javax.servlet.ServletResponse
        Overrides:
        getLocale in class javax.servlet.ServletResponseWrapper
      • addDateHeader

        public void addDateHeader(java.lang.String name,
                         long date)
        Specified by:
        addDateHeader in interface javax.servlet.http.HttpServletResponse
        Overrides:
        addDateHeader in class javax.servlet.http.HttpServletResponseWrapper
      • addHeader

        public void addHeader(java.lang.String name,
                     java.lang.String value)
        Specified by:
        addHeader in interface javax.servlet.http.HttpServletResponse
        Overrides:
        addHeader in class javax.servlet.http.HttpServletResponseWrapper
      • addIntHeader

        public void addIntHeader(java.lang.String name,
                        int value)
        Specified by:
        addIntHeader in interface javax.servlet.http.HttpServletResponse
        Overrides:
        addIntHeader in class javax.servlet.http.HttpServletResponseWrapper
      • setHeader

        public void setHeader(java.lang.String name,
                     java.lang.String value)
        Specified by:
        setHeader in interface javax.servlet.http.HttpServletResponse
        Overrides:
        setHeader in class javax.servlet.http.HttpServletResponseWrapper
      • setInternalHeader

        public void setInternalHeader(java.lang.String name,
                             java.lang.String value)
        Specified by:
        setInternalHeader in interface com.ibm.wsspi.webcontainer.servlet.IExtendedResponse
      • setHeader

        public void setHeader(java.lang.String name,
                     java.lang.String value,
                     boolean checkInclude)
        Specified by:
        setHeader in interface com.ibm.wsspi.webcontainer.servlet.IExtendedResponse
      • setIntHeader

        public void setIntHeader(java.lang.String name,
                        int value)
        Specified by:
        setIntHeader in interface javax.servlet.http.HttpServletResponse
        Overrides:
        setIntHeader in class javax.servlet.http.HttpServletResponseWrapper
      • setDateHeader

        public void setDateHeader(java.lang.String name,
                         long value)
        Specified by:
        setDateHeader in interface javax.servlet.http.HttpServletResponse
        Overrides:
        setDateHeader in class javax.servlet.http.HttpServletResponseWrapper
      • containsHeader

        public boolean containsHeader(java.lang.String name)
        Specified by:
        containsHeader in interface javax.servlet.http.HttpServletResponse
        Overrides:
        containsHeader in class javax.servlet.http.HttpServletResponseWrapper
      • getWriter

        public java.io.PrintWriter getWriter()
                                      throws java.io.IOException,
                                             java.lang.IllegalStateException
        Specified by:
        getWriter in interface javax.servlet.ServletResponse
        Overrides:
        getWriter in class javax.servlet.ServletResponseWrapper
        Throws:
        java.io.IOException
        java.lang.IllegalStateException
      • setStatus

        public void setStatus(int sc)
        Specified by:
        setStatus in interface javax.servlet.http.HttpServletResponse
        Overrides:
        setStatus in class javax.servlet.http.HttpServletResponseWrapper
      • setStatus

        public void setStatus(int sc,
                     java.lang.String message)
        Specified by:
        setStatus in interface javax.servlet.http.HttpServletResponse
        Overrides:
        setStatus in class javax.servlet.http.HttpServletResponseWrapper
      • sendError

        public void sendError(int sc)
                       throws java.io.IOException
        Specified by:
        sendError in interface javax.servlet.http.HttpServletResponse
        Overrides:
        sendError in class javax.servlet.http.HttpServletResponseWrapper
        Throws:
        java.io.IOException
      • sendError

        public void sendError(int sc,
                     java.lang.String message)
                       throws java.io.IOException
        Specified by:
        sendError in interface javax.servlet.http.HttpServletResponse
        Overrides:
        sendError in class javax.servlet.http.HttpServletResponseWrapper
        Throws:
        java.io.IOException
      • encodeURL

        public java.lang.String encodeURL(java.lang.String url)
        Specified by:
        encodeURL in interface javax.servlet.http.HttpServletResponse
        Overrides:
        encodeURL in class javax.servlet.http.HttpServletResponseWrapper
      • encodeUrl

        public java.lang.String encodeUrl(java.lang.String url)
        Specified by:
        encodeUrl in interface javax.servlet.http.HttpServletResponse
        Overrides:
        encodeUrl in class javax.servlet.http.HttpServletResponseWrapper
      • sendRedirect

        public void sendRedirect(java.lang.String uri)
                          throws java.io.IOException
        Specified by:
        sendRedirect in interface javax.servlet.http.HttpServletResponse
        Overrides:
        sendRedirect in class javax.servlet.http.HttpServletResponseWrapper
        Throws:
        java.io.IOException
      • sendRedirect303

        public void sendRedirect303(java.lang.String uri)
                             throws java.io.IOException
        Specified by:
        sendRedirect303 in interface com.ibm.wsspi.webcontainer.servlet.IExtendedResponse
        Throws:
        java.io.IOException
      • encodeRedirectURL

        public java.lang.String encodeRedirectURL(java.lang.String url)
        Specified by:
        encodeRedirectURL in interface javax.servlet.http.HttpServletResponse
        Overrides:
        encodeRedirectURL in class javax.servlet.http.HttpServletResponseWrapper
      • encodeRedirectUrl

        public java.lang.String encodeRedirectUrl(java.lang.String url)
        Specified by:
        encodeRedirectUrl in interface javax.servlet.http.HttpServletResponse
        Overrides:
        encodeRedirectUrl in class javax.servlet.http.HttpServletResponseWrapper
      • finishOutput

        protected void finishOutput(boolean toByteArray)
                             throws java.io.IOException
        Throws:
        java.io.IOException
      • finish

        public void finish()
                    throws java.io.IOException
        Specified by:
        finish in interface com.ibm.wsspi.webcontainer.servlet.IExtendedResponse
        Throws:
        java.io.IOException
      • close

        public void close()
                   throws java.io.IOException
        Throws:
        java.io.IOException
      • getOutputBuffer

        public byte[] getOutputBuffer()
                               throws java.io.IOException
        Throws:
        java.io.IOException
      • getByteBufferList

        public java.util.List<com.ibm.wsspi.buffermgmt.WsByteBuffer> getByteBufferList()
                                                                                throws java.io.IOException
        Throws:
        java.io.IOException
      • getOutputBufferAsString

        public java.lang.String getOutputBufferAsString()
                                                 throws java.io.IOException
        Get the output from the response outputstream as a String. This method should only be used to retrieve content that is known to be text based. Using this method to retrieve binary data will corrupt the response data.
        Throws:
        java.io.IOException
      • getHeaderNames

        public com.ibm.websphere.servlet.response.CollectionEnumerationHybrid<java.lang.String> getHeaderNames()
        Retrieve the names of the header fields that have been set on this response.
        Specified by:
        getHeaderNames in interface StoredResponseCompat
        Specified by:
        getHeaderNames in interface javax.servlet.http.HttpServletResponse
        Overrides:
        getHeaderNames in class javax.servlet.http.HttpServletResponseWrapper
      • getAddedHeaderNames

        public java.util.Enumeration getAddedHeaderNames()
        Retrieve only the headers set in the include
      • getHeader

        public java.lang.String getHeader(java.lang.String name)
        Retrieve a response header field by name.
        Specified by:
        getHeader in interface javax.servlet.http.HttpServletResponse
        Overrides:
        getHeader in class javax.servlet.http.HttpServletResponseWrapper
      • getIntHeader

        public int getIntHeader(java.lang.String name)
        Retrieve a response header as an int.
      • getDateHeader

        public long getDateHeader(java.lang.String name)
        Retrieve a response header as a date.
      • containsError

        public boolean containsError()
        Returns true if sendError() was called on this response.
      • getErrorMessage

        public java.lang.String getErrorMessage()
        Returns the error message as reported by the sendError() method.
      • getErrorStatusCode

        public int getErrorStatusCode()
        Returns the status code as reported by the sendError() method.
      • getStatusCode

        public int getStatusCode()
        Returns the status code as specifed by the setStatus() method.
        Specified by:
        getStatusCode in interface com.ibm.wsspi.webcontainer.servlet.IExtendedResponse
      • getStatusMessage

        public java.lang.String getStatusMessage()
        Returns the status message as reported by the setStatus() method.
      • getRedirectURI

        public java.lang.String getRedirectURI()
        Returns the target URI of the redirect as specified by the sendRedirect() method.
      • isRedirected

        public boolean isRedirected()
        Returns true if sendRedirect() was called.
      • getCharacterEncoding

        public java.lang.String getCharacterEncoding()
        Return the character encoding as specified in the charset flag of the content-type.
        Specified by:
        getCharacterEncoding in interface javax.servlet.ServletResponse
        Overrides:
        getCharacterEncoding in class javax.servlet.ServletResponseWrapper
      • getContentType

        public java.lang.String getContentType()
        Specified by:
        getContentType in interface javax.servlet.ServletResponse
        Overrides:
        getContentType in class javax.servlet.ServletResponseWrapper
      • getCookies

        public javax.servlet.http.Cookie[] getCookies()
        Return the cookies that were set using the addCookie() method.
      • getLastModified

        public long getLastModified()
        Returns the date that the data was last modifed in this response or -1 if unknown. This method returns the date value specified in the last-modified header.
      • isExpired

        public boolean isExpired()
        Return true if the data in this response has expired. This method is useful for caches to determine if the response is up-to-date or if if it should be cleared from the cache. This method returns false by default, subclasses should overload this method to provide their own expiration policies.
      • transferResponse

        public void transferResponse(javax.servlet.http.HttpServletResponse target)
                              throws java.io.IOException
        Copy the contents of this response to another HttpServletResponse. This method is optimized to quickly transfer the contents of this response into another response. This method is useful when this response is cached to generate the same response later.
        Throws:
        java.io.IOException
      • resetBuffer

        public void resetBuffer()
        Clears the content of the underlying buffer in the response without clearing headers or status code.
        Specified by:
        resetBuffer in interface javax.servlet.ServletResponse
        Overrides:
        resetBuffer in class javax.servlet.ServletResponseWrapper
        Since:
        2.3
      • fireOutputStreamRetrievedEvent

        public void fireOutputStreamRetrievedEvent(javax.servlet.ServletOutputStream sos)
        Specified by:
        fireOutputStreamRetrievedEvent in interface com.ibm.wsspi.webcontainer.servlet.IExtendedResponse
      • fireWriterRetrievedEvent

        public void fireWriterRetrievedEvent(java.io.PrintWriter pw)
        Specified by:
        fireWriterRetrievedEvent in interface com.ibm.wsspi.webcontainer.servlet.IExtendedResponse
      • registerOutputMethodListener

        public void registerOutputMethodListener(com.ibm.wsspi.webcontainer.servlet.IOutputMethodListener listener)
        Specified by:
        registerOutputMethodListener in interface com.ibm.wsspi.webcontainer.servlet.IExtendedResponse
      • destroy

        public void destroy()
        Specified by:
        destroy in interface com.ibm.wsspi.webcontainer.servlet.IExtendedResponse
      • initForNextResponse

        public void initForNextResponse(IResponse res)
        Specified by:
        initForNextResponse in interface com.ibm.wsspi.webcontainer.servlet.IExtendedResponse
      • start

        public void start()
        Specified by:
        start in interface com.ibm.wsspi.webcontainer.servlet.IExtendedResponse
      • setInclude

        public void setInclude(boolean isInclude)
      • setInternalHeaderSettable

        public void setInternalHeaderSettable(boolean internalHeaderSettable)
      • buildResponseData

        public void buildResponseData(com.ibm.wsspi.webcontainer.servlet.IExtendedResponse response)
      • buildWriterData

        public void buildWriterData(com.ibm.wsspi.webcontainer.servlet.IExtendedResponse response)
      • alertClose

        public void alertClose()
        Specified by:
        alertClose in interface com.ibm.wsspi.webcontainer.util.IOutputStreamObserver
      • alertException

        public void alertException()
        Specified by:
        alertException in interface com.ibm.wsspi.webcontainer.util.IOutputStreamObserver
      • alertFirstFlush

        public void alertFirstFlush()
        Specified by:
        alertFirstFlush in interface com.ibm.wsspi.webcontainer.util.IOutputStreamObserver
      • alertFirstWrite

        public void alertFirstWrite()
        Specified by:
        alertFirstWrite in interface com.ibm.wsspi.webcontainer.util.IOutputStreamObserver
      • closeResponseOutput

        public void closeResponseOutput(boolean b)
        Specified by:
        closeResponseOutput in interface com.ibm.wsspi.webcontainer.servlet.IExtendedResponse
      • removeCookie

        public void removeCookie(java.lang.String cookieName)
        Specified by:
        removeCookie in interface com.ibm.wsspi.webcontainer.servlet.IExtendedResponse
      • isOutputWritten

        public boolean isOutputWritten()
        Specified by:
        isOutputWritten in interface com.ibm.wsspi.webcontainer.servlet.IExtendedResponse
IBM WebSphere Application ServerTM
Release 8.5