public class Response extends Object implements HttpResponse, javax.servlet.http.HttpServletResponse
| Modifier and Type | Field and Description |
|---|---|
protected boolean |
appCommitted
The application commit flag.
|
protected Connector |
connector
Associated Catalina connector.
|
protected Context |
context
Associated context.
|
protected org.glassfish.grizzly.http.server.Response |
coyoteResponse
Coyote response.
|
protected boolean |
error
The error flag.
|
protected ResponseFacade |
facade
The facade associated with this response.
|
protected SimpleDateFormat |
format
The date format we will use for creating date headers.
|
static String |
HTTP_RESPONSE_DATE_HEADER |
protected boolean |
included
The included flag.
|
protected static String |
info
Descriptive information about this Response implementation.
|
protected OutputBuffer |
outputBuffer
The associated output buffer.
|
protected CoyoteOutputStream |
outputStream
The associated output stream.
|
protected org.glassfish.grizzly.http.util.CharChunk |
redirectURLCC
Recyclable buffer to hold the redirect URL.
|
protected Request |
request
The request with which this response is associated.
|
protected boolean |
upgrade |
protected org.glassfish.grizzly.http.util.UEncoder |
urlEncoder
URL encoder.
|
protected boolean |
usingOutputStream
Using output stream flag.
|
protected boolean |
usingWriter
Using writer flag.
|
protected CoyoteWriter |
writer
The associated writer.
|
SC_ACCEPTED, SC_BAD_GATEWAY, SC_BAD_REQUEST, SC_CONFLICT, SC_CONTINUE, SC_CREATED, SC_EXPECTATION_FAILED, SC_FORBIDDEN, SC_FOUND, 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 and Description |
|---|
Response() |
Response(boolean chunkingDisabled) |
| Modifier and Type | Method and Description |
|---|---|
void |
addCookie(javax.servlet.http.Cookie cookie)
Add the specified Cookie to those that will be included with
this Response.
|
void |
addDateHeader(String name,
long value)
Add the specified date header to the specified value.
|
void |
addHeader(String name,
String value)
Add the specified header to the specified value.
|
void |
addIntHeader(String name,
int value)
Add the specified integer header to the specified value.
|
void |
addSessionCookieInternal(javax.servlet.http.Cookie cookie)
Special method for adding a session cookie as we should be overriding
any previous
|
boolean |
containsHeader(String name)
Has the specified header been set already in this response?
|
javax.servlet.ServletOutputStream |
createOutputStream()
Create and return a ServletOutputStream to write the content
associated with this Response.
|
protected CoyoteWriter |
createWriter(OutputBuffer outbuf)
Create an instance of CoyoteWriter
|
String |
encode(String url)
Apply URL Encoding to the given URL without adding session identifier
et al associated to this response.
|
String |
encodeRedirectUrl(String url)
Deprecated.
As of Version 2.1 of the Java Servlet API, use
encodeRedirectURL() instead. |
String |
encodeRedirectURL(String url)
Encode the session identifier associated with this response
into the specified redirect URL, if necessary.
|
String |
encodeUrl(String url)
Deprecated.
As of Version 2.1 of the Java Servlet API, use
encodeURL() instead. |
String |
encodeURL(String url)
Encode the session identifier associated with this response
into the specified URL, if necessary.
|
void |
finishResponse()
Perform whatever actions are required to flush and close the output
stream or writer, in a single operation.
|
void |
flushBuffer()
Flush the buffer and commit this response.
|
int |
getBufferSize()
Return the actual buffer size used for this Response.
|
String |
getCharacterEncoding()
Return the character encoding used for this Response.
|
Connector |
getConnector()
Return the Connector through which this Request was received.
|
int |
getContentCount()
Return the number of bytes actually written to the output stream.
|
int |
getContentLength()
Return the content length that was set or calculated for this Response.
|
String |
getContentType()
Return the content type that was set or calculated for this response,
or
null if no content type was set. |
Context |
getContext()
Return the Context within which this Request is being processed.
|
protected String |
getCookieString(javax.servlet.http.Cookie cookie)
Gets the string representation of the given cookie.
|
org.glassfish.grizzly.http.server.Response |
getCoyoteResponse()
Get the Coyote response.
|
String |
getDetailMessage()
Gets detail error message.
|
String |
getHeader(String name)
Return the value for the specified header, or
null if this
header has not been set. |
Collection<String> |
getHeaderNames() |
Collection<String> |
getHeaders(String name) |
boolean |
getIncluded()
Return the "processing inside an include" flag.
|
String |
getInfo()
Return descriptive information about this Response implementation and
the corresponding version number, in the format
<description>/<version>. |
Locale |
getLocale()
Return the Locale assigned to this response.
|
String |
getMessage()
Return the error message that was set with
sendError()
for this Response. |
javax.servlet.ServletOutputStream |
getOutputStream()
Return the servlet output stream associated with this Response.
|
PrintWriter |
getReporter()
Return a PrintWriter that can be used to render error messages,
regardless of whether a stream or writer has already been acquired.
|
Request |
getRequest()
Return the Request with which this Response is associated.
|
javax.servlet.http.HttpServletResponse |
getResponse()
Return the
ServletResponse for which this object
is the facade. |
int |
getStatus()
Return the HTTP status code associated with this Response.
|
OutputStream |
getStream()
Return the output stream associated with this Response.
|
Supplier<Map<String,String>> |
getTrailerFields() |
PrintWriter |
getWriter()
Return the writer associated with this Response.
|
boolean |
isAppCommitted()
Application commit flag accessor.
|
boolean |
isCommitted()
Has the output of this response already been committed?
|
protected boolean |
isEncodeable(String location)
Return
true if the specified URL should be encoded with
a session identifier. |
boolean |
isError()
Error flag accessor.
|
boolean |
isSuspended()
Suspended flag accessor.
|
void |
recycle()
Release all object references, and initialize instance variables, in
preparation for reuse of this object.
|
void |
removeSessionCookies()
Removes any Set-Cookie response headers whose value contains the
string JSESSIONID
|
void |
reset()
Clear any content written to the buffer.
|
void |
reset(int status,
String message)
Reset this response, and specify the values for the HTTP status code
and corresponding message.
|
void |
resetBuffer()
Reset the data buffer but not any status or header information.
|
void |
resetBuffer(boolean resetWriterStreamFlags)
Reset the data buffer and the using Writer/Stream flags but not any
status or header information.
|
void |
sendAcknowledgement()
Send an acknowledgment of a request.
|
void |
sendError(int status)
Send an error response with the specified status and a
default message.
|
void |
sendError(int status,
String message)
Send an error response with the specified status and message.
|
void |
sendRedirect(String location)
Sends a temporary redirect to the specified redirect location URL.
|
void |
sendRedirect(String location,
boolean isTemporary)
Sends a temporary or permanent redirect to the specified redirect
location URL.
|
void |
setAppCommitted(boolean appCommitted)
Set the application commit flag.
|
void |
setBufferSize(int size)
Set the buffer size to be used for this Response.
|
void |
setCharacterEncoding(String charset) |
void |
setConnector(Connector connector)
Set the Connector through which this Request was received.
|
void |
setContentLength(int length)
Set the content length (in bytes) for this Response.
|
void |
setContentLengthLong(long length)
Sets the length of the content body in the response In HTTP servlets,
this method sets the HTTP Content-Length header.
|
void |
setContentType(String type)
Set the content type for this Response.
|
void |
setContext(Context context)
Set the Context within which this Request is being processed.
|
void |
setCoyoteResponse(org.glassfish.grizzly.http.server.Response coyoteResponse)
Set the Coyote response.
|
void |
setDateHeader(String name,
long value)
Set the specified date header to the specified value.
|
void |
setDetailMessage(String message)
Sets detail error message.
|
static void |
setEnforceScope(boolean enforce)
Set whether or not to enforce scope checking of this object.
|
void |
setError()
Set the error flag.
|
void |
setHeader(String name,
String value)
Set the specified header to the specified value.
|
void |
setIncluded(boolean included)
Set the "processing inside an include" flag.
|
void |
setIntHeader(String name,
int value)
Set the specified integer header to the specified value.
|
void |
setLocale(Locale locale)
Set the Locale that is appropriate for this response, including
setting the appropriate character encoding.
|
void |
setRequest(Request request)
Set the Request with which this Response is associated.
|
void |
setStatus(int status)
Set the HTTP status to be returned with this response.
|
void |
setStatus(int status,
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.
|
void |
setStream(OutputStream stream)
Set the output stream associated with this Response.
|
void |
setSuspended(boolean suspended)
Set the suspended flag.
|
void |
setTrailerFields(Supplier<Map<String,String>> supplier) |
void |
setUpgrade(boolean upgrade) |
protected String |
toAbsolute(String location)
Convert (if necessary) and return the absolute URL that represents the
resource referenced by this possibly relative URL.
|
protected String |
toEncoded(String url,
String sessionId)
Return the specified URL with the specified session identifier
suitably encoded.
|
public static final String HTTP_RESPONSE_DATE_HEADER
protected static final String info
protected SimpleDateFormat format
protected Context context
protected boolean upgrade
protected Connector connector
protected org.glassfish.grizzly.http.server.Response coyoteResponse
protected OutputBuffer outputBuffer
protected CoyoteOutputStream outputStream
protected CoyoteWriter writer
protected boolean appCommitted
protected boolean included
protected boolean error
protected boolean usingOutputStream
protected boolean usingWriter
protected org.glassfish.grizzly.http.util.UEncoder urlEncoder
protected org.glassfish.grizzly.http.util.CharChunk redirectURLCC
protected Request request
protected ResponseFacade facade
public static void setEnforceScope(boolean enforce)
public Connector getConnector()
getConnector in interface Responsepublic void setConnector(Connector connector)
setConnector in interface Responseconnector - The new connectorpublic void setCoyoteResponse(org.glassfish.grizzly.http.server.Response coyoteResponse)
coyoteResponse - The Coyote responsepublic org.glassfish.grizzly.http.server.Response getCoyoteResponse()
public Context getContext()
getContext in interface Responsepublic void setContext(Context context)
getContextPath(),
and thus enables parsing of the request URI.setContext in interface Responsecontext - The newly associated Contextpublic void recycle()
public int getContentCount()
getContentCount in interface Responsepublic void setAppCommitted(boolean appCommitted)
setAppCommitted in interface ResponseappCommitted - The new application committed flag valuepublic boolean isAppCommitted()
isAppCommitted in interface Responsepublic boolean getIncluded()
getIncluded in interface Responsepublic void setIncluded(boolean included)
setIncluded in interface Responseincluded - true if we are currently inside a
RequestDispatcher.include(), else falsepublic String getInfo()
<description>/<version>.public Request getRequest()
getRequest in interface Responsepublic void setRequest(Request request)
setRequest in interface Responserequest - The new associated requestpublic javax.servlet.http.HttpServletResponse getResponse()
ServletResponse for which this object
is the facade.getResponse in interface Responsepublic OutputStream getStream()
public void setStream(OutputStream stream)
public void setSuspended(boolean suspended)
setSuspended in interface Responsesuspended - The new suspended flag valuepublic boolean isSuspended()
isSuspended in interface Responsepublic void setDetailMessage(String message)
setDetailMessage in interface Responsemessage - detail error messagepublic String getDetailMessage()
getDetailMessage in interface Responsepublic javax.servlet.ServletOutputStream createOutputStream()
throws IOException
createOutputStream in interface ResponseIOException - if an input/output error occurspublic void finishResponse()
throws IOException
finishResponse in interface ResponseIOException - if an input/output error occurspublic int getContentLength()
getContentLength in interface Responsepublic String getContentType()
null if no content type was set.getContentType in interface javax.servlet.ServletResponsegetContentType in interface Responsepublic PrintWriter getReporter() throws IOException
getReporter in interface ResponseIOException - if an input/output error occurspublic void flushBuffer()
throws IOException
flushBuffer in interface javax.servlet.ServletResponseIOException - if an input/output error occurspublic int getBufferSize()
getBufferSize in interface javax.servlet.ServletResponsepublic String getCharacterEncoding()
getCharacterEncoding in interface javax.servlet.ServletResponsepublic void setCharacterEncoding(String charset)
setCharacterEncoding in interface javax.servlet.ServletResponsepublic javax.servlet.ServletOutputStream getOutputStream()
throws IOException
getOutputStream in interface javax.servlet.ServletResponseIllegalStateException - if getWriter has
already been called for this responseIOException - if an input/output error occurspublic Locale getLocale()
getLocale in interface javax.servlet.ServletResponsepublic PrintWriter getWriter() throws IOException
getWriter in interface javax.servlet.ServletResponseIllegalStateException - if getOutputStream has
already been called for this responseIOException - if an input/output error occurspublic boolean isCommitted()
isCommitted in interface javax.servlet.ServletResponsepublic void reset()
reset in interface javax.servlet.ServletResponseIllegalStateException - if this response has already
been committedpublic void resetBuffer()
resetBuffer in interface javax.servlet.ServletResponseresetBuffer in interface ResponseIllegalStateException - if the response has already
been committedpublic void resetBuffer(boolean resetWriterStreamFlags)
resetBuffer in interface ResponseresetWriterStreamFlags - true if the internal
usingWriter, usingOutputStream,
isCharacterEncodingSet flags should also be resetIllegalStateException - if the response has already
been committedpublic void setBufferSize(int size)
setBufferSize in interface javax.servlet.ServletResponsesize - The new buffer sizeIllegalStateException - if this method is called after
output has been committed for this responsepublic void setContentLength(int length)
setContentLength in interface javax.servlet.ServletResponselength - The new content lengthpublic void setContentLengthLong(long length)
setContentLengthLong in interface javax.servlet.ServletResponselength - The new content lengthpublic void setContentType(String type)
setContentType in interface javax.servlet.ServletResponsetype - The new content typepublic void setLocale(Locale locale)
setLocale in interface javax.servlet.ServletResponselocale - The new localepublic String getHeader(String name)
null if this
header has not been set. If more than one value was added for this
name, only the first is returned; use getHeaders(String) to
retrieve all of them.getHeader in interface javax.servlet.http.HttpServletResponsegetHeader in interface HttpResponsename - Header name to look uppublic Collection<String> getHeaderNames()
getHeaderNames in interface javax.servlet.http.HttpServletResponsegetHeaderNames in interface HttpResponseCollection of the names
of the headers of this responsepublic Collection<String> getHeaders(String name)
getHeaders in interface javax.servlet.http.HttpServletResponsegetHeaders in interface HttpResponsename - the name of the response header whose values to returnCollection of the values
of the response header with the given namepublic String getMessage()
sendError()
for this Response.getMessage in interface HttpResponsepublic int getStatus()
getStatus in interface javax.servlet.http.HttpServletResponsegetStatus in interface HttpResponsepublic void reset(int status,
String message)
reset in interface HttpResponseIllegalStateException - if this response has already been
committedpublic void addCookie(javax.servlet.http.Cookie cookie)
addCookie in interface javax.servlet.http.HttpServletResponsecookie - Cookie to be addedpublic void addSessionCookieInternal(javax.servlet.http.Cookie cookie)
addSessionCookieInternal in interface HttpResponsecookie - public void addDateHeader(String name, long value)
addDateHeader in interface javax.servlet.http.HttpServletResponsename - Name of the header to setvalue - Date value to be setpublic void addHeader(String name, String value)
addHeader in interface javax.servlet.http.HttpServletResponsename - Name of the header to setvalue - Value to be setpublic void addIntHeader(String name, int value)
addIntHeader in interface javax.servlet.http.HttpServletResponsename - Name of the header to setvalue - Integer value to be setpublic boolean containsHeader(String name)
containsHeader in interface javax.servlet.http.HttpServletResponsename - Name of the header to checkpublic String encodeRedirectURL(String url)
encodeRedirectURL in interface javax.servlet.http.HttpServletResponseurl - URL to be encodedpublic Supplier<Map<String,String>> getTrailerFields()
getTrailerFields in interface javax.servlet.http.HttpServletResponsepublic void setTrailerFields(Supplier<Map<String,String>> supplier)
setTrailerFields in interface javax.servlet.http.HttpServletResponsepublic String encodeRedirectUrl(String url)
encodeRedirectURL() instead.encodeRedirectUrl in interface javax.servlet.http.HttpServletResponseurl - URL to be encodedpublic String encodeURL(String url)
encodeURL in interface javax.servlet.http.HttpServletResponseurl - URL to be encodedpublic String encodeUrl(String url)
encodeURL() instead.encodeUrl in interface javax.servlet.http.HttpServletResponseurl - URL to be encodedpublic String encode(String url)
public void sendAcknowledgement()
throws IOException
sendAcknowledgement in interface HttpResponsesendAcknowledgement in interface ResponseIOException - if an input/output error occurspublic void sendError(int status)
throws IOException
sendError in interface javax.servlet.http.HttpServletResponsestatus - HTTP status code to sendIllegalStateException - if this response has
already been committedIOException - if an input/output error occurspublic void sendError(int status,
String message)
throws IOException
sendError in interface javax.servlet.http.HttpServletResponsestatus - HTTP status code to sendmessage - Corresponding message to sendIllegalStateException - if this response has
already been committedIOException - if an input/output error occurspublic void sendRedirect(String location) throws IOException
sendRedirect in interface javax.servlet.http.HttpServletResponselocation - Location URL to redirect toIllegalStateException - if this response has
already been committedIOException - if an input/output error occurspublic void sendRedirect(String location, boolean isTemporary) throws IOException
location - Location URL to redirect toisTemporary - true if the redirect is supposed to be temporary,
false if permanentIllegalStateException - if this response has
already been committedIOException - if an input/output error occurspublic void setDateHeader(String name, long value)
setDateHeader in interface javax.servlet.http.HttpServletResponsename - Name of the header to setvalue - Date value to be setpublic void setHeader(String name, String value)
setHeader in interface javax.servlet.http.HttpServletResponsename - Name of the header to setvalue - Value to be setpublic void setIntHeader(String name, int value)
setIntHeader in interface javax.servlet.http.HttpServletResponsename - Name of the header to setvalue - Integer value to be setpublic void setStatus(int status)
setStatus in interface javax.servlet.http.HttpServletResponsestatus - The new HTTP statuspublic void setStatus(int status,
String message)
setStatus in interface javax.servlet.http.HttpServletResponsestatus - The new HTTP statusmessage - The associated text messageprotected boolean isEncodeable(String location)
true if the specified URL should be encoded with
a session identifier. This will be true if all of the following
conditions are met:
location - Absolute URL to be validatedprotected String toAbsolute(String location)
location - URL to be (possibly) converted and then returnedIllegalArgumentException - if a MalformedURLException is
thrown when converting the relative URL to an absolute oneprotected String toEncoded(String url, String sessionId)
url - URL to be encoded with the session idsessionId - Session id to be included in the encoded URLprotected CoyoteWriter createWriter(OutputBuffer outbuf)
protected String getCookieString(javax.servlet.http.Cookie cookie)
cookie - The cookie whose string representation to getpublic void removeSessionCookies()
public void setUpgrade(boolean upgrade)
Copyright © 2019. All rights reserved.