org.apache.coyote

## Class Response

- java.lang.Object
- - org.apache.coyote.Response

-     public final class Response
      extends Object

  Response object.
  Author:
    James Duncan Davidson [duncan@eng.sun.com], Jason Hunter [jch@eng.sun.com], James Todd [gonzo@eng.sun.com], Harish Prabandham, Hans Bergsten <hans@gefionsoftware.com>, Remy Maucherat

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `ActionHook` | `hook` Action hook.

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `Response()`

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `acknowledge()`
    `void` | `action(ActionCode actionCode, Object param)`
    `void` | `addHeader(String name, String value)`
    `boolean` | `containsHeader(String name)` Warning: This method always returns `false`for Content-Type and Content-Length.``
    `void` | `doWrite(ByteChunk chunk)` Write a chunk of bytes.
    `void` | `finish()`
    `long` | `getBytesWritten(boolean flush)` Bytes written to socket - i.e. after compression, chunking, etc.
    `String` | `getCharacterEncoding()`
    `long` | `getCommitTime()` Return the time the response was committed (based on System.currentTimeMillis).
    `String` | `getContentLanguage()` Return the content language.
    `int` | `getContentLength()`
    `long` | `getContentLengthLong()`
    `String` | `getContentType()`
    `long` | `getContentWritten()` Bytes written by application - i.e. before compression, chunking, etc.
    `Exception` | `getErrorException()` Get the Exception that occurred during request processing.
    `ActionHook` | `getHook()`
    `Locale` | `getLocale()`
    `String` | `getMessage()` Get the status message.
    `MimeHeaders` | `getMimeHeaders()`
    `Object` | `getNote(int pos)`
    `OutputBuffer` | `getOutputBuffer()`
    `Request` | `getRequest()`
    `int` | `getStatus()`
    `boolean` | `isCommitted()`
    `boolean` | `isExceptionPresent()`
    `void` | `recycle()`
    `void` | `reset()`
    `void` | `sendHeaders()` Signal that we're done with the headers, and body will follow.
    `void` | `setCharacterEncoding(String charset)`
    `void` | `setCommitted(boolean v)`
    `void` | `setContentLength(long contentLength)`
    `void` | `setContentType(String type)` Sets the content type.
    `void` | `setContentTypeNoCharset(String type)`
    `void` | `setErrorException(Exception ex)` Set the error Exception that occurred during request processing.
    `void` | `setHeader(String name, String value)`
    `void` | `setHook(ActionHook hook)`
    `void` | `setLocale(Locale locale)` Called explicitly by user to set the Content-Language and the default encoding
    `void` | `setMessage(String message)` Set the status message.
    `void` | `setNote(int pos, Object value)`
    `void` | `setOutputBuffer(OutputBuffer outputBuffer)`
    `void` | `setRequest(Request req)`
    `void` | `setStatus(int status)` Set the response status

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Field Detail

    - #### hook

          public ActionHook hook

      Action hook.

  - ### Constructor Detail

    - #### Response

          public Response()

  - ### Method Detail

    - #### getRequest

          public Request getRequest()

    - #### setRequest

          public void setRequest(Request req)

    - #### getOutputBuffer

          public OutputBuffer getOutputBuffer()

    - #### setOutputBuffer

          public void setOutputBuffer(OutputBuffer outputBuffer)

    - #### getMimeHeaders

          public MimeHeaders getMimeHeaders()

    - #### getHook

          public ActionHook getHook()

    - #### setHook

          public void setHook(ActionHook hook)

    - #### setNote

          public final void setNote(int pos,
                     Object value)

    - #### getNote

          public final Object getNote(int pos)

    - #### action

          public void action(ActionCode actionCode,
                    Object param)

    - #### getStatus

          public int getStatus()

    - #### setStatus

          public void setStatus(int status)

      Set the response status

    - #### getMessage

          public String getMessage()

      Get the status message.

    - #### setMessage

          public void setMessage(String message)

      Set the status message.

    - #### 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).
      Returns:
        the time the response was committed

    - #### setErrorException

          public void setErrorException(Exception ex)

      Set the error Exception that occurred during request processing.

    - #### getErrorException

          public Exception getErrorException()

      Get the Exception that occurred during request processing.

    - #### isExceptionPresent

          public boolean isExceptionPresent()

    - #### reset

          public void reset()
                     throws IllegalStateException

      Throws:
        `IllegalStateException`

    - #### finish

          public void finish()

    - #### acknowledge

          public void acknowledge()

    - #### containsHeader

          public boolean containsHeader(String name)

      Warning: This method always returns `false`for Content-Type and Content-Length.``

    - #### setHeader

          public void setHeader(String name,
                       String value)

    - #### addHeader

          public void addHeader(String name,
                       String value)

    - #### 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 Locale getLocale()

    - #### setLocale

          public void setLocale(Locale locale)

      Called explicitly by user to set the Content-Language and the default encoding

    - #### getContentLanguage

          public String getContentLanguage()

      Return the content language.

    - #### setCharacterEncoding

          public void setCharacterEncoding(String charset)

    - #### getCharacterEncoding

          public String getCharacterEncoding()

    - #### setContentType

          public void setContentType(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().
      Parameters:
        `type` - the content type

    - #### setContentTypeNoCharset

          public void setContentTypeNoCharset(String type)

    - #### getContentType

          public String getContentType()

    - #### setContentLength

          public void setContentLength(long contentLength)

    - #### getContentLength

          public int getContentLength()

    - #### getContentLengthLong

          public long getContentLengthLong()

    - #### doWrite

          public void doWrite(ByteChunk chunk)
                       throws IOException

      Write a chunk of bytes.
      Throws:
        `IOException`

    - #### recycle

          public void recycle()

    - #### getContentWritten

          public long getContentWritten()

      Bytes written by application - i.e. before compression, chunking, etc.

    - #### getBytesWritten

          public long getBytesWritten(boolean flush)

      Bytes written to socket - i.e. after compression, chunking, etc.

Copyright © 2000-2016 Apache Software Foundation. All Rights Reserved.