All Packages  Class Hierarchy  This Package  Previous  Next  Index

Class sun.servlet.http.HttpResponse

java.lang.Object
   |
   +----sun.servlet.http.HttpResponse

public class HttpResponse
extends Object
implements HttpServletResponse, Observer
This class represents an HTTP servlet response.


Variable Index

 o con
The connection for this servlet.
 o headerBytes
The response header size in bytes.
 o headers
The MIME headers for this response.
 o keepAlive
Set to true when keep-alive is enabled.
 o out
The output stream for writing response data.
 o protocol
The protocol of the response.
 o reason
The status message of the response.
 o status
The status code of the response.

Constructor Index

 o HttpResponse()
Creates a new HttpResponse object.

Method Index

 o containsHeader(String)
Returns true if the specified header field is contained in this response otherwise returns false.
 o finish()
Finishes the response.
 o getEntityBytes()
Returns the size of the entity data for this response.
 o getHeaders()
Returns the MIME headers for this response.
 o getKeepAlive()
Returns true if this connection should be kept alive.
 o getOutputStream()
Returns an output stream for writing response data.
 o getStatus()
Returns the status code of the response.
 o getTotalBytes()
Returns the total number of bytes for this response.
 o init(ServletConnection)
Initializes this response with the specified servlet connection.
 o next()
Begins the next response.
 o reason(int)
Returns a default reason phrase for the specified status code.
 o reset()
Resets the servlet response.
 o sendError(int)
Sends an error response to the client using the specified status code and no default message.
 o sendError(int, String)
Sends an error response to the client using the specified status code and detail message.
 o sendRedirect(String)
Sends a redirect response to the client using the specified redirect location URL.
 o setContentLength(int)
Sets the content length for this response.
 o setContentType(String)
Sets the content type for this response.
 o setDateHeader(String)
Sets a date header to the current time.
 o setDateHeader(String, long)
Sets a date header to the specified time.
 o setHeader(String, String)
Sets a header to the specified string value.
 o setIntHeader(String, int)
Sets a header to the specified integer value.
 o setKeepAlive(boolean)
Used to indicate whether this connection should be kept alive.
 o setProtocol(String)
Sets the protocol of the response.
 o setStatus(int)
Sets the status code and a default message for this response.
 o setStatus(int, String)
Sets the status code and message for this response.
 o update(Observable, Object)
This method is called for a full request when the servlet first writes to the output stream.
 o writeHeaders()

Variables

 o status
  protected int status
The status code of the response.

 o reason
  protected String reason
The status message of the response.

 o protocol
  protected String protocol
The protocol of the response.

 o headers
  protected final MimeHeaders headers
The MIME headers for this response.

 o out
  protected HttpOutputStream out
The output stream for writing response data.

 o con
  protected ServletConnection con
The connection for this servlet.

 o headerBytes
  protected int headerBytes
The response header size in bytes.

 o keepAlive
  protected boolean keepAlive
Set to true when keep-alive is enabled.

Constructors

 o HttpResponse
  public HttpResponse()
Creates a new HttpResponse object.

Methods

 o init
  public void init(ServletConnection con) throws IOException
Initializes this response with the specified servlet connection.

Parameters:
con - the servlet connection
 o next
  public void next()
Begins the next response.

 o finish
  public void finish() throws IOException
Finishes the response.

 o reset
  public void reset()
Resets the servlet response.

 o getTotalBytes
  public int getTotalBytes()
Returns the total number of bytes for this response.

 o getEntityBytes
  public int getEntityBytes()
Returns the size of the entity data for this response.

 o setProtocol
  public void setProtocol(String protocol)
Sets the protocol of the response. Should be called immediately after initializing the response.

 o setKeepAlive
  public void setKeepAlive(boolean enable)
Used to indicate whether this connection should be kept alive.

Parameters:
enable - if true then keep connection alive
 o getKeepAlive
  public boolean getKeepAlive()
Returns true if this connection should be kept alive.

 o setContentLength
  public void setContentLength(int len)
Sets the content length for this response.

Parameters:
len - the content length
 o setContentType
  public void setContentType(String type)
Sets the content type for this response.

Parameters:
type - the content type
 o getOutputStream
  public ServletOutputStream getOutputStream()
Returns an output stream for writing response data.

 o setStatus
  public void setStatus(int status,
                        String reason)
Sets the status code and message for this response.

Parameters:
status - the status code
reason - the status message
 o setStatus
  public void setStatus(int status)
Sets the status code and a default message for this response.

Parameters:
status - the status code
 o getStatus
  public int getStatus()
Returns the status code of the response.

 o setHeader
  public void setHeader(String name,
                        String s)
Sets a header to the specified string value.

Parameters:
name - the header name
s - the header string value
 o setIntHeader
  public void setIntHeader(String name,
                           int i)
Sets a header to the specified integer value.

Parameters:
name - the header name
i - the header integer value
 o setDateHeader
  public void setDateHeader(String name,
                            long t)
Sets a date header to the specified time.

Parameters:
name - the header name
t - the time in milliseconds since the epoch
 o setDateHeader
  public void setDateHeader(String name)
Sets a date header to the current time.

Parameters:
naem - the header name
 o containsHeader
  public boolean containsHeader(String name)
Returns true if the specified header field is contained in this response otherwise returns false.

Parameters:
name - the header filed name
 o getHeaders
  public MimeHeaders getHeaders()
Returns the MIME headers for this response.

 o reason
  protected String reason(int status)
Returns a default reason phrase for the specified status code.

 o sendError
  public void sendError(int status,
                        String msg) throws IOException
Sends an error response to the client using the specified status code and detail message.

Parameters:
status - the status code
msg - the detail message
Throws: IOException
if an I/O error has occurred
 o sendError
  public void sendError(int status) throws IOException
Sends an error response to the client using the specified status code and no default message.

Parameters:
sc - the status code
Throws: IOException
if an I/O error has occurred
 o sendRedirect
  public void sendRedirect(String location) throws IOException
Sends a redirect response to the client using the specified redirect location URL.

Parameters:
location - the redirect location URL
Throws: IOException
if an I/O error has occurred
 o update
  public void update(Observable obs,
                     Object obj)
This method is called for a full request when the servlet first writes to the output stream. This allows the HTTP headers to be written before the response entity data.

 o writeHeaders
  protected void writeHeaders() throws IOException

All Packages  Class Hierarchy  This Package  Previous  Next  Index