public interface Response
| Modifier and Type | Method and Description |
|---|---|
void |
addHeader(String name,
String value)
Adds a response header with the given name and value, not overwriting any previous values which
may have already been added.
|
void |
disableCompression()
Invoked to indicate that the response content is either already compressed, or is not compressable.
|
String |
encodeRedirectURL(String URL)
Encodes the URL for use as a redirect, ensuring that a session id is included (if a session exists, and as
necessary depending on the client browser's use of cookies).
|
String |
encodeURL(String URL)
Encodes the URL, ensuring that a session id is included (if a session exists, and as necessary depending on the
client browser's use of cookies).
|
OutputStream |
getOutputStream(String contentType)
Returns an OutputStream to which byte-oriented output may be sent.
|
PrintWriter |
getPrintWriter(String contentType)
Returns a PrintWriter object to which output may be sent.
|
boolean |
isCommitted()
Returns true if the response has already been sent, either as a redirect or as a stream of content.
|
void |
sendError(int sc,
String message)
Sends an error response to the client using the specified status.
|
void |
sendRedirect(Link link)
Sends a redirect to a link.
|
void |
sendRedirect(String URL)
Sends a redirect to the client.
|
void |
setContentLength(int length)
Sets the length of the content body in the response; this method sets the HTTP Content-Length header.
|
void |
setDateHeader(String name,
long date)
Sets a response header with the given name and date-value.
|
void |
setHeader(String name,
String value)
Sets a response header with the given name and value.
|
void |
setIntHeader(String name,
int value)
Sets a response header with the given name and integer value.
|
void |
setStatus(int sc)
Sets the status code for this response.
|
PrintWriter getPrintWriter(String contentType) throws IOException
contentType - the MIME content type for the output, typically "text/html"IOExceptionOutputStream getOutputStream(String contentType) throws IOException
contentType - the MIME content type for the output, often "application/octet-stream" or "text/plain" or one
of several othersIOExceptionvoid sendRedirect(String URL) throws IOException
URL - full or partial (relative) URL to send to the clientIOExceptionencodeRedirectURL(String)void sendRedirect(Link link) throws IOException
link - link to redirect to.IOExceptionvoid setStatus(int sc)
sendError method should be used instead.sc - the status codevoid sendError(int sc, String message) throws IOException
sc - the error status codemessage - the descriptive messageIOException - If an input or output exception occursIllegalStateException - If the response was committedvoid setContentLength(int length)
length - the length of the contentvoid setDateHeader(String name, long date)
name - the name of the header to setdate - the assigned date valuevoid setHeader(String name, String value)
name - the name of the header to setvalue - the assigned value@IncompatibleChange(release="5.4", details="Added method") void addHeader(String name, String value)
name - the name of the header to addvalue - the assigned valuevoid setIntHeader(String name, int value)
name - the name of the header to setvalue - the assigned integer valueString encodeURL(String URL)
URL - String encodeRedirectURL(String URL)
URL - boolean isCommitted()
void disableCompression()
5.6.4 - Copyright © 2003-2021 The Apache Software Foundation.