Class Response

  • public final class Response
    extends java.lang.Object
    Response object.
    James Duncan Davidson [], Jason Hunter [], James Todd [], Harish Prabandham, Hans Bergsten [], Remy Maucherat
    • Constructor Detail

      • Response

        public Response()
    • Method Detail

      • getRequest

        public Request getRequest()
      • setRequest

        public void setRequest​(Request req)
      • setOutputBuffer

        public void setOutputBuffer​(OutputBuffer outputBuffer)
      • setHook

        protected void setHook​(ActionHook hook)
      • setNote

        public void setNote​(int pos,
                            java.lang.Object value)
      • getNote

        public java.lang.Object getNote​(int pos)
      • action

        public void action​(ActionCode actionCode,
                           java.lang.Object param)
      • getStatus

        public int getStatus()
      • setStatus

        public void setStatus​(int status)
        Set the response status.
        status - The status value to set
      • getMessage

        public java.lang.String getMessage()
        Get the status message.
        The message associated with the current status
      • setMessage

        public void setMessage​(java.lang.String message)
        Set the status message.
        message - The status message to set
      • isCommitted

        public boolean isCommitted()
      • setCommitted

        public void setCommitted​(boolean v)
      • getCommitTime

        public long getCommitTime()
        Return the time the response was committed (based on System.currentTimeMillis).
        the time the response was committed
      • setErrorException

        public void setErrorException​(java.lang.Exception ex)
        Set the error Exception that occurred during the writing of the response processing.
        ex - The exception that occurred
      • getErrorException

        public java.lang.Exception getErrorException()
        Get the Exception that occurred during the writing of the response.
        The exception that occurred
      • isExceptionPresent

        public boolean isExceptionPresent()
      • setError

        public boolean setError()
        This method will be changed to return void in Tomcat 11 onwards
        Set the error flag.
        false if the error flag was already set
      • isError

        public boolean isError()
        Error flag accessor.
        true if the response has encountered an error
      • isErrorReportRequired

        public boolean isErrorReportRequired()
      • setErrorReported

        public boolean setErrorReported()
      • reset

        public void reset()
                   throws java.lang.IllegalStateException
      • containsHeader

        public boolean containsHeader​(java.lang.String name)
        Does the response contain the given header.
        Warning: This method always returns false for Content-Type and Content-Length.
        name - The name of the header of interest
        true if the response contains the header.
      • setHeader

        public void setHeader​(java.lang.String name,
                              java.lang.String value)
      • addHeader

        public void addHeader​(java.lang.String name,
                              java.lang.String value)
      • addHeader

        public void addHeader​(java.lang.String name,
                              java.lang.String value,
                              java.nio.charset.Charset charset)
      • setTrailerFields

        public void setTrailerFields​(java.util.function.Supplier<java.util.Map<java.lang.String,​java.lang.String>> supplier)
      • getTrailerFields

        public java.util.function.Supplier<java.util.Map<java.lang.String,​java.lang.String>> getTrailerFields()
      • sendHeaders

        public void sendHeaders()
        Signal that we're done with the headers, and body will follow. Any implementation needs to notify ContextManager, to allow interceptors to fix headers.
      • getLocale

        public java.util.Locale getLocale()
      • setLocale

        public void setLocale​(java.util.Locale locale)
        Called explicitly by user to set the Content-Language and the default encoding.
        locale - The locale to use for this response
      • getContentLanguage

        public java.lang.String getContentLanguage()
        Return the content language.
        The language code for the language currently associated with this response
      • setCharacterEncoding

        public void setCharacterEncoding​(java.lang.String characterEncoding)
        Overrides the character encoding used in the body of the response. This method must be called prior to writing output using getWriter().
        characterEncoding - The name of character encoding.
        Throws: - If the specified name is not recognised
      • getCharset

        public java.nio.charset.Charset getCharset()
      • getCharacterEncoding

        public java.lang.String getCharacterEncoding()
        The name of the current encoding
      • setContentType

        public void setContentType​(java.lang.String type)
        Sets the content type. This method must preserve any response charset that may already have been set via a call to response.setContentType(), response.setLocale(), or response.setCharacterEncoding().
        type - the content type
      • setContentTypeNoCharset

        public void setContentTypeNoCharset​(java.lang.String type)
      • getContentType

        public java.lang.String getContentType()
      • setContentLength

        public void setContentLength​(long contentLength)
      • getContentLength

        public int getContentLength()
      • getContentLengthLong

        public long getContentLengthLong()
      • doWrite

        public void doWrite​(java.nio.ByteBuffer chunk)
        Write a chunk of bytes.
        chunk - The ByteBuffer to write
        Throws: - If an I/O error occurs during the write
      • recycle

        public void recycle()
      • getContentWritten

        public long getContentWritten()
        Bytes written by application - i.e. before compression, chunking, etc.
        The total number of bytes written to the response by the application. This will not be the number of bytes written to the network which may be more or less than this value.
      • getBytesWritten

        public long getBytesWritten​(boolean flush)
        Bytes written to socket - i.e. after compression, chunking, etc.
        flush - Should any remaining bytes be flushed before returning the total? If false bytes remaining in the buffer will not be included in the returned value
        The total number of bytes written to the socket for this response
      • setWriteListener

        public void setWriteListener​(WriteListener listener)
      • isReady

        public boolean isReady()
      • checkRegisterForWrite

        public boolean checkRegisterForWrite()
      • onWritePossible

        public void onWritePossible()