## org.apache.catalina.connector
Class HttpResponseBase

    java.lang.Object
      org.apache.catalina.connector.ResponseBase
          org.apache.catalina.connector.HttpResponseBase

All Implemented Interfaces:
  HttpResponse, javax.servlet.http.HttpServletResponse, Response, javax.servlet.ServletResponse

public class HttpResponseBase
extends ResponseBase
implements HttpResponse, javax.servlet.http.HttpServletResponse

Convenience base implementation of the HttpResponse interface, which can be used for the `Response` implementation required by most `Connectors` that deal with HTTP. Only the connector-specific methods need to be implemented.

Version:
  $Revision: 466595 $ $Date: 2006-10-21 23:24:41 +0100 (Sat, 21 Oct 2006) $
Author:
  Craig R. McClanahan, Remy Maucherat

Nested Class Summary
`protected class` `HttpResponseBase.PrivilegedFlushBuffer` Deprecated.

Field Summary
`protected java.util.ArrayList` `cookies` Deprecated. The set of Cookies associated with this Response.
`protected HttpResponseFacade` `facade` Deprecated. The facade associated with this response.
`protected java.text.SimpleDateFormat` `format` Deprecated. The date format we will use for creating date headers.
`protected java.util.HashMap` `headers` Deprecated. The HTTP headers explicitly added via addHeader(), but not including those to be added with setContentLength(), setContentType(), and so on.
`protected static java.lang.String` `info` Deprecated. Descriptive information about this HttpResponse implementation.
`protected java.lang.String` `message` Deprecated. The error message set by `sendError()`.
`protected int` `status` Deprecated. The HTTP status code associated with this Response.
`protected static java.util.TimeZone` `zone` Deprecated. The time zone with which to construct date headers.

Fields inherited from class org.apache.catalina.connector.ResponseBase
`appCommitted, buffer, bufferCount, committed, connector, contentCount, contentLength, contentType, context, encoding, error, included, locale, output, request, sm, stream, suspended, writer`

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_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
`HttpResponseBase()` Deprecated.

Method Summary
`void` `addCookie(javax.servlet.http.Cookie cookie)` Deprecated. Add the specified Cookie to those that will be included with this Response.
`void` `addDateHeader(java.lang.String name, long value)` Deprecated. Add the specified date header to the specified value.
`void` `addHeader(java.lang.String name, java.lang.String value)` Deprecated. Add the specified header to the specified value.
`void` `addIntHeader(java.lang.String name, int value)` Deprecated. Add the specified integer header to the specified value.
`boolean` `containsHeader(java.lang.String name)` Deprecated. Has the specified header been set already in this response?
`java.lang.String` `encodeRedirectUrl(java.lang.String url)` Deprecated. As of Version 2.1 of the Java Servlet API, use `encodeRedirectURL()` instead.
`java.lang.String` `encodeRedirectURL(java.lang.String url)` Deprecated. Encode the session identifier associated with this response into the specified redirect URL, if necessary.
`java.lang.String` `encodeUrl(java.lang.String url)` Deprecated. As of Version 2.1 of the Java Servlet API, use `encodeURL()` instead.
`java.lang.String` `encodeURL(java.lang.String url)` Deprecated. Encode the session identifier associated with this response into the specified URL, if necessary.
`void` `finishResponse()` Deprecated. Perform whatever actions are required to flush and close the output stream or writer, in a single operation.
`void` `flushBuffer()` Deprecated. Flush the buffer and commit this response.
`javax.servlet.http.Cookie[]` `getCookies()` Deprecated. Return an array of all cookies set for this response, or a zero-length array if no cookies have been set.
`java.lang.String` `getHeader(java.lang.String name)` Deprecated. Return the value for the specified header, or `null` if this header has not been set.
`java.lang.String[]` `getHeaderNames()` Deprecated. Return an array of all the header names set for this response, or a zero-length array if no headers have been set.
`java.lang.String[]` `getHeaderValues(java.lang.String name)` Deprecated. Return an array of all the header values associated with the specified header name, or an zero-length array if there are no such header values.
`java.lang.String` `getMessage()` Deprecated. Return the error message that was set with `sendError()` for this Response.
`protected java.lang.String` `getProtocol()` Deprecated. Return the HTTP protocol version implemented by this response object.
`javax.servlet.ServletResponse` `getResponse()` Deprecated. Return the `ServletResponse` for which this object is the facade.
`int` `getStatus()` Deprecated. Return the HTTP status code associated with this Response.
`protected java.lang.String` `getStatusMessage(int status)` Deprecated. Returns a default status message for the specified HTTP status code.
`void` `recycle()` Deprecated. Release all object references, and initialize instance variables, in preparation for reuse of this object.
`void` `reset()` Deprecated. Clear any content written to the buffer.
`void` `reset(int status, java.lang.String message)` Deprecated. Reset this response, and specify the values for the HTTP status code and corresponding message.
`void` `sendAcknowledgement()` Deprecated. Send an acknowledgment of a request.
`void` `sendError(int status)` Deprecated. Send an error response with the specified status and a default message.
`void` `sendError(int status, java.lang.String message)` Deprecated. Send an error response with the specified status and message.
`protected void` `sendHeaders()` Deprecated. Send the HTTP response headers, if this has not already occurred.
`void` `sendRedirect(java.lang.String location)` Deprecated. Send a temporary redirect to the specified redirect location URL.
`void` `setContentLength(int length)` Deprecated. Set the content length (in bytes) for this Response.
`void` `setContentType(java.lang.String type)` Deprecated. Set the content type for this Response.
`void` `setDateHeader(java.lang.String name, long value)` Deprecated. Set the specified date header to the specified value.
`void` `setHeader(java.lang.String name, java.lang.String value)` Deprecated. Set the specified header to the specified value.
`void` `setIntHeader(java.lang.String name, int value)` Deprecated. Set the specified integer header to the specified value.
`void` `setLocale(java.util.Locale locale)` Deprecated. Set the Locale that is appropriate for this response, including setting the appropriate character encoding.
`void` `setStatus(int status)` Deprecated. Set the HTTP status to be returned with this response.
`void` `setStatus(int status, java.lang.String message)` Deprecated. As of Version 2.1 of the Java Servlet API, this method has been deprecated due to the ambiguous meaning of the message parameter.

Methods inherited from class org.apache.catalina.connector.ResponseBase

`createOutputStream, getBufferSize, getCharacterEncoding, getConnector, getContentCount, getContentLength, getContentType, getContext, getIncluded, getInfo, getLocale, getOutputStream, getReporter, getRequest, getStream, getWriter, isAppCommitted, isCommitted, isError, isSuspended, resetBuffer, setAppCommitted, setBufferSize, setConnector, setContext, setError, setIncluded, setRequest, setStream, setSuspended, write, write, write`

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Methods inherited from interface org.apache.catalina.Response
`createOutputStream, getConnector, getContentCount, getContentLength, getContentType, getContext, getIncluded, getInfo, getReporter, getRequest, getStream, isAppCommitted, isError, isSuspended, resetBuffer, setAppCommitted, setConnector, setContext, setError, setIncluded, setRequest, setStream, setSuspended`

Methods inherited from interface javax.servlet.ServletResponse
`getBufferSize, getCharacterEncoding, getLocale, getOutputStream, getWriter, isCommitted, resetBuffer, setBufferSize`

Field Detail

### cookies

    protected java.util.ArrayList cookies

  Deprecated.
  The set of Cookies associated with this Response.

### format

    protected final java.text.SimpleDateFormat format

  Deprecated.
  The date format we will use for creating date headers.

### facade

    protected HttpResponseFacade facade

  Deprecated.
  The facade associated with this response.

### headers

    protected java.util.HashMap headers

  Deprecated.
  The HTTP headers explicitly added via addHeader(), but not including those to be added with setContentLength(), setContentType(), and so on. This collection is keyed by the header name, and the elements are ArrayLists containing the associated values that have been set.

### info

    protected static final java.lang.String info

  Deprecated.
  Descriptive information about this HttpResponse implementation.

  See Also:
    Constant Field Values

### message

    protected java.lang.String message

  Deprecated.
  The error message set by `sendError()`.

### status

    protected int status

  Deprecated.
  The HTTP status code associated with this Response.

### zone

    protected static final java.util.TimeZone zone

  Deprecated.
  The time zone with which to construct date headers.

Constructor Detail

### HttpResponseBase

    public HttpResponseBase()

  Deprecated.

Method Detail

### getResponse

    public javax.servlet.ServletResponse getResponse()

  Deprecated.
  Return the `ServletResponse` for which this object is the facade.

  Specified by:
    `getResponse` in interface `Response`
  Overrides:
    `getResponse` in class `ResponseBase`

### finishResponse

    public void finishResponse()
                        throws java.io.IOException

  Deprecated.
  Perform whatever actions are required to flush and close the output stream or writer, in a single operation.

  Specified by:
    `finishResponse` in interface `Response`
  Overrides:
    `finishResponse` in class `ResponseBase`
  Throws:
    `java.io.IOException` - if an input/output error occurs

### getCookies

    public javax.servlet.http.Cookie[] getCookies()

  Deprecated.
  Return an array of all cookies set for this response, or a zero-length array if no cookies have been set.

  Specified by:
    `getCookies` in interface `HttpResponse`

### getHeader

    public java.lang.String getHeader(java.lang.String name)

  Deprecated.
  Return the value for the specified header, or `null` if this header has not been set. If more than one value was added for this name, only the first is returned; use getHeaderValues() to retrieve all of them.

  Specified by:
    `getHeader` in interface `HttpResponse`
  Parameters:
    `name` - Header name to look up

### getHeaderNames

    public java.lang.String[] getHeaderNames()

  Deprecated.
  Return an array of all the header names set for this response, or a zero-length array if no headers have been set.

  Specified by:
    `getHeaderNames` in interface `HttpResponse`

### getHeaderValues

    public java.lang.String[] getHeaderValues(java.lang.String name)

  Deprecated.
  Return an array of all the header values associated with the specified header name, or an zero-length array if there are no such header values.

  Specified by:
    `getHeaderValues` in interface `HttpResponse`
  Parameters:
    `name` - Header name to look up

### getMessage

    public java.lang.String getMessage()

  Deprecated.
  Return the error message that was set with `sendError()` for this Response.

  Specified by:
    `getMessage` in interface `HttpResponse`

### getStatus

    public int getStatus()

  Deprecated.
  Return the HTTP status code associated with this Response.

  Specified by:
    `getStatus` in interface `HttpResponse`

### recycle

    public void recycle()

  Deprecated.
  Release all object references, and initialize instance variables, in preparation for reuse of this object.

  Specified by:
    `recycle` in interface `Response`
  Overrides:
    `recycle` in class `ResponseBase`

### reset

    public void reset(int status,
                      java.lang.String message)

  Deprecated.
  Reset this response, and specify the values for the HTTP status code and corresponding message.

  Specified by:
    `reset` in interface `HttpResponse`
  Throws:
    `java.lang.IllegalStateException` - if this response has already been committed

### getStatusMessage

    protected java.lang.String getStatusMessage(int status)

  Deprecated.
  Returns a default status message for the specified HTTP status code.

  Parameters:
    `status` - The status code for which a message is desired

### getProtocol

    protected java.lang.String getProtocol()

  Deprecated.
  Return the HTTP protocol version implemented by this response object. (This method must be overridden by subclasses of this as to correctly return the highest HTTP version number supported as specified in Section 3.1 of RFC-2616).

  Returns:
    A string in the form of "HTTP/1.0" ...

### sendHeaders

    protected void sendHeaders()
                        throws java.io.IOException

  Deprecated.
  Send the HTTP response headers, if this has not already occurred.

  Throws:
    `java.io.IOException`

### flushBuffer

    public void flushBuffer()
                     throws java.io.IOException

  Deprecated.
  Flush the buffer and commit this response. If this is the first output, send the HTTP headers prior to the user data.

  Specified by:
    `flushBuffer` in interface `javax.servlet.ServletResponse`
  Overrides:
    `flushBuffer` in class `ResponseBase`
  Throws:
    `java.io.IOException` - if an input/output error occurs

### reset

    public void reset()

  Deprecated.
  Clear any content written to the buffer. In addition, all cookies and headers are cleared, and the status is reset.

  Specified by:
    `reset` in interface `javax.servlet.ServletResponse`
  Overrides:
    `reset` in class `ResponseBase`
  Throws:
    `java.lang.IllegalStateException` - if this response has already been committed

### setContentLength

    public void setContentLength(int length)

  Deprecated.
  Set the content length (in bytes) for this Response.

  Specified by:
    `setContentLength` in interface `javax.servlet.ServletResponse`
  Overrides:
    `setContentLength` in class `ResponseBase`
  Parameters:
    `length` - The new content length

### setContentType

    public void setContentType(java.lang.String type)

  Deprecated.
  Set the content type for this Response.

  Specified by:
    `setContentType` in interface `javax.servlet.ServletResponse`
  Overrides:
    `setContentType` in class `ResponseBase`
  Parameters:
    `type` - The new content type

### setLocale

    public void setLocale(java.util.Locale locale)

  Deprecated.
  Set the Locale that is appropriate for this response, including setting the appropriate character encoding.

  Specified by:
    `setLocale` in interface `javax.servlet.ServletResponse`
  Overrides:
    `setLocale` in class `ResponseBase`
  Parameters:
    `locale` - The new locale

### addCookie

    public void addCookie(javax.servlet.http.Cookie cookie)

  Deprecated.
  Add the specified Cookie to those that will be included with this Response.

  Specified by:
    `addCookie` in interface `javax.servlet.http.HttpServletResponse`
  Parameters:
    `cookie` - Cookie to be added

### addDateHeader

    public void addDateHeader(java.lang.String name,
                              long value)

  Deprecated.
  Add the specified date header to the specified value.

  Specified by:
    `addDateHeader` in interface `javax.servlet.http.HttpServletResponse`
  Parameters:
    `name` - Name of the header to set
    `value` - Date value to be set

### addHeader

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

  Deprecated.
  Add the specified header to the specified value.

  Specified by:
    `addHeader` in interface `javax.servlet.http.HttpServletResponse`
  Parameters:
    `name` - Name of the header to set
    `value` - Value to be set

### addIntHeader

    public void addIntHeader(java.lang.String name,
                             int value)

  Deprecated.
  Add the specified integer header to the specified value.

  Specified by:
    `addIntHeader` in interface `javax.servlet.http.HttpServletResponse`
  Parameters:
    `name` - Name of the header to set
    `value` - Integer value to be set

### containsHeader

    public boolean containsHeader(java.lang.String name)

  Deprecated.
  Has the specified header been set already in this response?

  Specified by:
    `containsHeader` in interface `javax.servlet.http.HttpServletResponse`
  Parameters:
    `name` - Name of the header to check

### encodeRedirectURL

    public java.lang.String encodeRedirectURL(java.lang.String url)

  Deprecated.
  Encode the session identifier associated with this response into the specified redirect URL, if necessary.

  Specified by:
    `encodeRedirectURL` in interface `javax.servlet.http.HttpServletResponse`
  Parameters:
    `url` - URL to be encoded

### encodeRedirectUrl

    public java.lang.String encodeRedirectUrl(java.lang.String url)

  Deprecated. As of Version 2.1 of the Java Servlet API, use `encodeRedirectURL()` instead.

  Encode the session identifier associated with this response into the specified redirect URL, if necessary.

  Specified by:
    `encodeRedirectUrl` in interface `javax.servlet.http.HttpServletResponse`
  Parameters:
    `url` - URL to be encoded

### encodeURL

    public java.lang.String encodeURL(java.lang.String url)

  Deprecated.
  Encode the session identifier associated with this response into the specified URL, if necessary.

  Specified by:
    `encodeURL` in interface `javax.servlet.http.HttpServletResponse`
  Parameters:
    `url` - URL to be encoded

### encodeUrl

    public java.lang.String encodeUrl(java.lang.String url)

  Deprecated. As of Version 2.1 of the Java Servlet API, use `encodeURL()` instead.

  Encode the session identifier associated with this response into the specified URL, if necessary.

  Specified by:
    `encodeUrl` in interface `javax.servlet.http.HttpServletResponse`
  Parameters:
    `url` - URL to be encoded

### sendAcknowledgement

    public void sendAcknowledgement()
                             throws java.io.IOException

  Deprecated.
  Send an acknowledgment of a request.

  Specified by:
    `sendAcknowledgement` in interface `Response`
  Throws:
    `java.io.IOException` - if an input/output error occurs

### sendError

    public void sendError(int status)
                   throws java.io.IOException

  Deprecated.
  Send an error response with the specified status and a default message.

  Specified by:
    `sendError` in interface `javax.servlet.http.HttpServletResponse`
  Parameters:
    `status` - HTTP status code to send
  Throws:
    `java.lang.IllegalStateException` - if this response has already been committed
    `java.io.IOException` - if an input/output error occurs

### sendError

    public void sendError(int status,
                          java.lang.String message)
                   throws java.io.IOException

  Deprecated.
  Send an error response with the specified status and message.

  Specified by:
    `sendError` in interface `javax.servlet.http.HttpServletResponse`
  Parameters:
    `status` - HTTP status code to send
    `message` - Corresponding message to send
  Throws:
    `java.lang.IllegalStateException` - if this response has already been committed
    `java.io.IOException` - if an input/output error occurs

### sendRedirect

    public void sendRedirect(java.lang.String location)
                      throws java.io.IOException

  Deprecated.
  Send a temporary redirect to the specified redirect location URL.

  Specified by:
    `sendRedirect` in interface `javax.servlet.http.HttpServletResponse`
  Parameters:
    `location` - Location URL to redirect to
  Throws:
    `java.lang.IllegalStateException` - if this response has already been committed
    `java.io.IOException` - if an input/output error occurs

### setDateHeader

    public void setDateHeader(java.lang.String name,
                              long value)

  Deprecated.
  Set the specified date header to the specified value.

  Specified by:
    `setDateHeader` in interface `javax.servlet.http.HttpServletResponse`
  Parameters:
    `name` - Name of the header to set
    `value` - Date value to be set

### setHeader

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

  Deprecated.
  Set the specified header to the specified value.

  Specified by:
    `setHeader` in interface `javax.servlet.http.HttpServletResponse`
  Parameters:
    `name` - Name of the header to set
    `value` - Value to be set

### setIntHeader

    public void setIntHeader(java.lang.String name,
                             int value)

  Deprecated.
  Set the specified integer header to the specified value.

  Specified by:
    `setIntHeader` in interface `javax.servlet.http.HttpServletResponse`
  Parameters:
    `name` - Name of the header to set
    `value` - Integer value to be set

### setStatus

    public void setStatus(int status)

  Deprecated.
  Set the HTTP status to be returned with this response.

  Specified by:
    `setStatus` in interface `javax.servlet.http.HttpServletResponse`
  Parameters:
    `status` - The new HTTP status

### setStatus

    public void setStatus(int status,
                          java.lang.String message)

  Deprecated. As of Version 2.1 of the Java Servlet API, this method has been deprecated due to the ambiguous meaning of the message parameter.

  Set the HTTP status and message to be returned with this response.

  Specified by:
    `setStatus` in interface `javax.servlet.http.HttpServletResponse`
  Parameters:
    `status` - The new HTTP status
    `message` - The associated text message

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