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.
-
con
- The connection for this servlet.
-
headerBytes
- The response header size in bytes.
-
headers
- The MIME headers for this response.
-
keepAlive
- Set to true when keep-alive is enabled.
-
out
- The output stream for writing response data.
-
protocol
- The protocol of the response.
-
reason
- The status message of the response.
-
status
- The status code of the response.
-
HttpResponse()
- Creates a new HttpResponse object.
-
containsHeader(String)
- Returns true if the specified header field is contained in this response
otherwise returns false.
-
finish()
- Finishes the response.
-
getEntityBytes()
- Returns the size of the entity data for this response.
-
getHeaders()
- Returns the MIME headers for this response.
-
getKeepAlive()
- Returns true if this connection should be kept alive.
-
getOutputStream()
- Returns an output stream for writing response data.
-
getStatus()
- Returns the status code of the response.
-
getTotalBytes()
- Returns the total number of bytes for this response.
-
init(ServletConnection)
- Initializes this response with the specified servlet connection.
-
next()
- Begins the next response.
-
reason(int)
- Returns a default reason phrase for the specified status code.
-
reset()
- Resets the servlet response.
-
sendError(int)
- Sends an error response to the client using the specified status
code and no default message.
-
sendError(int, String)
- Sends an error response to the client using the specified status
code and detail message.
-
sendRedirect(String)
- Sends a redirect response to the client using the specified redirect
location URL.
-
setContentLength(int)
- Sets the content length for this response.
-
setContentType(String)
- Sets the content type for this response.
-
setDateHeader(String)
- Sets a date header to the current time.
-
setDateHeader(String, long)
- Sets a date header to the specified time.
-
setHeader(String, String)
- Sets a header to the specified string value.
-
setIntHeader(String, int)
- Sets a header to the specified integer value.
-
setKeepAlive(boolean)
- Used to indicate whether this connection should be kept alive.
-
setProtocol(String)
- Sets the protocol of the response.
-
setStatus(int)
- Sets the status code and a default message for this response.
-
setStatus(int, String)
- Sets the status code and message for this response.
-
update(Observable, Object)
- This method is called for a full request when the servlet first writes
to the output stream.
-
writeHeaders()
-
status
protected int status
- The status code of the response.
reason
protected String reason
- The status message of the response.
protocol
protected String protocol
- The protocol of the response.
headers
protected final MimeHeaders headers
- The MIME headers for this response.
out
protected HttpOutputStream out
- The output stream for writing response data.
con
protected ServletConnection con
- The connection for this servlet.
headerBytes
protected int headerBytes
- The response header size in bytes.
keepAlive
protected boolean keepAlive
- Set to true when keep-alive is enabled.
HttpResponse
public HttpResponse()
- Creates a new HttpResponse object.
init
public void init(ServletConnection con) throws IOException
- Initializes this response with the specified servlet connection.
- Parameters:
- con - the servlet connection
next
public void next()
- Begins the next response.
finish
public void finish() throws IOException
- Finishes the response.
reset
public void reset()
- Resets the servlet response.
getTotalBytes
public int getTotalBytes()
- Returns the total number of bytes for this response.
getEntityBytes
public int getEntityBytes()
- Returns the size of the entity data for this response.
setProtocol
public void setProtocol(String protocol)
- Sets the protocol of the response. Should be called immediately after
initializing the response.
setKeepAlive
public void setKeepAlive(boolean enable)
- Used to indicate whether this connection should be kept alive.
- Parameters:
- enable - if true then keep connection alive
getKeepAlive
public boolean getKeepAlive()
- Returns true if this connection should be kept alive.
setContentLength
public void setContentLength(int len)
- Sets the content length for this response.
- Parameters:
- len - the content length
setContentType
public void setContentType(String type)
- Sets the content type for this response.
- Parameters:
- type - the content type
getOutputStream
public ServletOutputStream getOutputStream()
- Returns an output stream for writing response data.
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
setStatus
public void setStatus(int status)
- Sets the status code and a default message for this response.
- Parameters:
- status - the status code
getStatus
public int getStatus()
- Returns the status code of the response.
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
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
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
setDateHeader
public void setDateHeader(String name)
- Sets a date header to the current time.
- Parameters:
- naem - the header name
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
getHeaders
public MimeHeaders getHeaders()
- Returns the MIME headers for this response.
reason
protected String reason(int status)
- Returns a default reason phrase for the specified status code.
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
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
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
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.
writeHeaders
protected void writeHeaders() throws IOException
All Packages Class Hierarchy This Package Previous Next Index