Class StoredResponse

java.lang.Object
jakarta.servlet.ServletResponseWrapper
jakarta.servlet.http.HttpServletResponseWrapper
com.ibm.websphere.servlet.response.StoredResponse
All Implemented Interfaces:
StoredResponseCompat<CollectionEnumerationHybrid<String>>, IExtendedResponse, ServletResponseExtended, com.ibm.wsspi.webcontainer.util.IOutputStreamObserver, com.ibm.wsspi.webcontainer.util.IResponseOutput, Serializable, jakarta.servlet.http.HttpServletResponse, jakarta.servlet.ServletResponse
Direct Known Subclasses:
ChainedResponse

public class StoredResponse extends jakarta.servlet.http.HttpServletResponseWrapper implements StoredResponseCompat<CollectionEnumerationHybrid<String>>, jakarta.servlet.http.HttpServletResponse, Serializable, com.ibm.wsspi.webcontainer.util.IResponseOutput, 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:
  • Constructor Details

    • StoredResponse

      public StoredResponse()
    • StoredResponse

      public StoredResponse(boolean isInclude)
    • StoredResponse

      public StoredResponse(ServletResponseExtended extResponse, boolean isInclude)
  • Method Details

    • 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(jakarta.servlet.http.Cookie cookie)
      Specified by:
      addCookie in interface jakarta.servlet.http.HttpServletResponse
      Overrides:
      addCookie in class jakarta.servlet.http.HttpServletResponseWrapper
    • getIResponse

      public IResponse getIResponse()
      Specified by:
      getIResponse in interface IExtendedResponse
      Specified by:
      getIResponse in interface ServletResponseExtended
    • getOutputStream

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

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

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

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

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

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

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

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

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

      public Vector[] getHeaderTable()
      Specified by:
      getHeaderTable in interface IExtendedResponse
      Specified by:
      getHeaderTable in interface ServletResponseExtended
    • addSessionCookie

      public void addSessionCookie(jakarta.servlet.http.Cookie cookie)
      Specified by:
      addSessionCookie in interface IExtendedResponse
      Specified by:
      addSessionCookie in interface ServletResponseExtended
    • setLocale

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

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

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

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

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

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

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

      public void setInternalHeader(String name, String value)
      Specified by:
      setInternalHeader in interface IExtendedResponse
    • setHeader

      public void setHeader(String name, String value, boolean checkInclude)
      Specified by:
      setHeader in interface IExtendedResponse
      Specified by:
      setHeader in interface ServletResponseExtended
    • setIntHeader

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

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

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

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

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

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

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

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

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

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

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

      public void sendRedirect303(String uri) throws IOException
      Specified by:
      sendRedirect303 in interface IExtendedResponse
      Throws:
      IOException
    • encodeRedirectURL

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

      public String encodeRedirectUrl(String url)
      Specified by:
      encodeRedirectUrl in interface jakarta.servlet.http.HttpServletResponse
      Overrides:
      encodeRedirectUrl in class jakarta.servlet.http.HttpServletResponseWrapper
    • finish

      public void finish() throws IOException
      Specified by:
      finish in interface IExtendedResponse
      Throws:
      IOException
    • close

      public void close() throws IOException
      Throws:
      IOException
    • getOutputBuffer

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

      public List<com.ibm.wsspi.bytebuffer.WsByteBuffer> getByteBufferList() throws IOException
      Throws:
      IOException
    • getOutputBufferAsString

      public String getOutputBufferAsString() throws 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:
      IOException
    • getHeaderNames

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

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

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

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

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

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

      public com.ibm.websphere.servlet.error.ServletErrorReport getError()
    • getErrorMessage

      public 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 IExtendedResponse
      Specified by:
      getStatusCode in interface ServletResponseExtended
    • getStatusMessage

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

      public 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 String getCharacterEncoding()
      Return the character encoding as specified in the charset flag of the content-type.
      Specified by:
      getCharacterEncoding in interface jakarta.servlet.ServletResponse
      Overrides:
      getCharacterEncoding in class jakarta.servlet.ServletResponseWrapper
    • getContentType

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

      public jakarta.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(jakarta.servlet.http.HttpServletResponse target) throws 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:
      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 jakarta.servlet.ServletResponse
      Overrides:
      resetBuffer in class jakarta.servlet.ServletResponseWrapper
      Since:
      2.3
    • fireOutputStreamRetrievedEvent

      public void fireOutputStreamRetrievedEvent(jakarta.servlet.ServletOutputStream sos)
      Specified by:
      fireOutputStreamRetrievedEvent in interface IExtendedResponse
    • fireWriterRetrievedEvent

      public void fireWriterRetrievedEvent(PrintWriter pw)
      Specified by:
      fireWriterRetrievedEvent in interface IExtendedResponse
    • registerOutputMethodListener

      public void registerOutputMethodListener(IOutputMethodListener listener)
      Specified by:
      registerOutputMethodListener in interface IExtendedResponse
    • destroy

      public void destroy()
      Specified by:
      destroy in interface IExtendedResponse
    • initForNextResponse

      public void initForNextResponse(IResponse res)
      Specified by:
      initForNextResponse in interface IExtendedResponse
    • start

      public void start()
      Specified by:
      start in interface IExtendedResponse
    • setInclude

      public void setInclude(boolean isInclude)
    • setInternalHeaderSettable

      public void setInternalHeaderSettable(boolean internalHeaderSettable)
    • buildResponseData

      public void buildResponseData(ServletResponseExtended response)
    • buildWriterData

      public void buildWriterData(ServletResponseExtended 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 IExtendedResponse
    • removeCookie

      public void removeCookie(String cookieName)
      Specified by:
      removeCookie in interface IExtendedResponse
    • isOutputWritten

      public boolean isOutputWritten()
      Specified by:
      isOutputWritten in interface IExtendedResponse