Package org.apache.catalina.core
Class DummyResponse
- java.lang.Object
-
- org.apache.catalina.core.DummyResponse
-
- All Implemented Interfaces:
jakarta.servlet.http.HttpServletResponse,jakarta.servlet.ServletResponse,HttpResponse,Response
public class DummyResponse extends Object implements HttpResponse, jakarta.servlet.http.HttpServletResponse
Dummy response object, used for JSP precompilation.- Version:
- $Revision: 1.2 $ $Date: 2005/12/08 01:27:34 $
- Author:
- Remy Maucherat
-
-
Field Summary
-
Fields inherited from interface jakarta.servlet.http.HttpServletResponse
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 Summary
Constructors Constructor Description DummyResponse()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddCookie(jakarta.servlet.http.Cookie cookie)voidaddDateHeader(String name, long value)voidaddHeader(String name, String value)voidaddIntHeader(String name, int value)voidaddSessionCookieInternal(jakarta.servlet.http.Cookie cookie)Special method for adding a session cookie as we should be overriding any previousbooleancontainsHeader(String name)jakarta.servlet.ServletOutputStreamcreateOutputStream()Create and return a ServletOutputStream to write the content associated with this Response.Stringencode(String url)Apply URL Encoding to the given URL without adding session identifier et al associated to this response.StringencodeRedirectUrl(String url)StringencodeRedirectURL(String url)StringencodeUrl(String url)StringencodeURL(String url)voidfinishResponse()Perform whatever actions are required to flush and close the output stream or writer, in a single operation.voidflushBuffer()intgetBufferSize()StringgetCharacterEncoding()ConnectorgetConnector()Return the Connector through which this Response is returned.intgetContentCount()Return the number of bytes actually written to the output stream.intgetContentLength()Return the content length that was set or calculated for this Response.StringgetContentType()Return the content type that was set or calculated for this response, ornullif no content type was set.ContextgetContext()Return the Context with which this Response is associated.StringgetDetailMessage()Gets detail error message.StringgetHeader(String name)Return the value for the specified header, ornullif this header has not been set.Collection<String>getHeaderNames()Collection<String>getHeaders(String name)booleangetIncluded()Return the "processing inside an include" flag.StringgetInfo()Return descriptive information about this Response implementation and the corresponding version number, in the format<description>/<version>.LocalegetLocale()StringgetMessage()Return the error message that was set withsendError()for this Response.jakarta.servlet.ServletOutputStreamgetOutputStream()PrintWritergetReporter()Return a PrintWriter that can be used to render error messages, regardless of whether a stream or writer has already been acquired.RequestgetRequest()Return the Request with which this Response is associated.jakarta.servlet.ServletResponsegetResponse()Return theServletResponsefor which this object is the facade.intgetStatus()Return the HTTP status code associated with this Response.OutputStreamgetStream()Return the output stream associated with this Response.PrintWritergetWriter()booleanisAppCommitted()Application commit flag accessor.booleanisCommitted()booleanisError()Error flag accessor.booleanisSuspended()Suspended flag accessor.voidrecycle()Release all object references, and initialize instance variables, in preparation for reuse of this object.voidreset()voidreset(int status, String message)Reset this response, and specify the values for the HTTP status code and corresponding message.voidresetBuffer()Reset the data buffer but not any status or header information.voidresetBuffer(boolean resetWriterStreamFlags)Reset the data buffer and the using Writer/Stream flags but not any status or header information.voidsendAcknowledgement()Send an acknowledgment of a request.voidsendError(int status)voidsendError(int status, String message)voidsendRedirect(String location)voidsetAppCommitted(boolean appCommitted)Set the application commit flag.voidsetBufferSize(int size)voidsetCharacterEncoding(String charEncoding)voidsetConnector(Connector connector)Set the Connector through which this Response is returned.voidsetContentLength(int length)voidsetContentLengthLong(long length)voidsetContentType(String type)voidsetContext(Context context)Set the Context with which this Response is associated.voidsetDateHeader(String name, long value)voidsetDetailMessage(String msg)Sets detail error message.voidsetError()Set the error flag.voidsetHeader(String name, String value)voidsetIncluded(boolean included)Set the "processing inside an include" flag.voidsetIntHeader(String name, int value)voidsetLocale(Locale locale)voidsetRequest(Request request)Set the Request with which this Response is associated.voidsetStatus(int status)voidsetStatus(int status, String message)voidsetStream(OutputStream stream)Set the output stream associated with this Response.voidsetSuspended(boolean suspended)Set the suspended flag.voidwrite(byte[] b)voidwrite(byte[] b, int off, int len)voidwrite(int b)
-
-
-
Method Detail
-
setAppCommitted
public void setAppCommitted(boolean appCommitted)
Description copied from interface:ResponseSet the application commit flag.- Specified by:
setAppCommittedin interfaceResponse- Parameters:
appCommitted- The new application committed flag value
-
isAppCommitted
public boolean isAppCommitted()
Description copied from interface:ResponseApplication commit flag accessor.- Specified by:
isAppCommittedin interfaceResponse
-
getConnector
public Connector getConnector()
Description copied from interface:ResponseReturn the Connector through which this Response is returned.- Specified by:
getConnectorin interfaceResponse
-
setConnector
public void setConnector(Connector connector)
Description copied from interface:ResponseSet the Connector through which this Response is returned.- Specified by:
setConnectorin interfaceResponse- Parameters:
connector- The new connector
-
getContentCount
public int getContentCount()
Description copied from interface:ResponseReturn the number of bytes actually written to the output stream.- Specified by:
getContentCountin interfaceResponse
-
getContext
public Context getContext()
Description copied from interface:ResponseReturn the Context with which this Response is associated.- Specified by:
getContextin interfaceResponse
-
setContext
public void setContext(Context context)
Description copied from interface:ResponseSet the Context with which this Response is associated. This should be called as soon as the appropriate Context is identified.- Specified by:
setContextin interfaceResponse- Parameters:
context- The associated Context
-
getIncluded
public boolean getIncluded()
Description copied from interface:ResponseReturn the "processing inside an include" flag.- Specified by:
getIncludedin interfaceResponse
-
setIncluded
public void setIncluded(boolean included)
Description copied from interface:ResponseSet the "processing inside an include" flag.- Specified by:
setIncludedin interfaceResponse- Parameters:
included-trueif we are currently inside a RequestDispatcher.include(), elsefalse
-
getInfo
public String getInfo()
Description copied from interface:ResponseReturn descriptive information about this Response implementation and the corresponding version number, in the format<description>/<version>.
-
getRequest
public Request getRequest()
Description copied from interface:ResponseReturn the Request with which this Response is associated.- Specified by:
getRequestin interfaceResponse
-
setRequest
public void setRequest(Request request)
Description copied from interface:ResponseSet the Request with which this Response is associated.- Specified by:
setRequestin interfaceResponse- Parameters:
request- The new associated request
-
getResponse
public jakarta.servlet.ServletResponse getResponse()
Description copied from interface:ResponseReturn theServletResponsefor which this object is the facade.- Specified by:
getResponsein interfaceResponse
-
getStream
public OutputStream getStream()
Description copied from interface:ResponseReturn the output stream associated with this Response.
-
setStream
public void setStream(OutputStream stream)
Description copied from interface:ResponseSet the output stream associated with this Response.
-
setSuspended
public void setSuspended(boolean suspended)
Description copied from interface:ResponseSet the suspended flag.- Specified by:
setSuspendedin interfaceResponse- Parameters:
suspended- The new suspended flag value
-
isSuspended
public boolean isSuspended()
Description copied from interface:ResponseSuspended flag accessor.- Specified by:
isSuspendedin interfaceResponse
-
setError
public void setError()
Description copied from interface:ResponseSet the error flag.
-
isError
public boolean isError()
Description copied from interface:ResponseError flag accessor.
-
createOutputStream
public jakarta.servlet.ServletOutputStream createOutputStream() throws IOExceptionDescription copied from interface:ResponseCreate and return a ServletOutputStream to write the content associated with this Response.- Specified by:
createOutputStreamin interfaceResponse- Throws:
IOException- if an input/output error occurs
-
finishResponse
public void finishResponse() throws IOExceptionDescription copied from interface:ResponsePerform whatever actions are required to flush and close the output stream or writer, in a single operation.- Specified by:
finishResponsein interfaceResponse- Throws:
IOException- if an input/output error occurs
-
getContentLength
public int getContentLength()
Description copied from interface:ResponseReturn the content length that was set or calculated for this Response.- Specified by:
getContentLengthin interfaceResponse
-
getContentType
public String getContentType()
Description copied from interface:ResponseReturn the content type that was set or calculated for this response, ornullif no content type was set.- Specified by:
getContentTypein interfaceResponse- Specified by:
getContentTypein interfacejakarta.servlet.ServletResponse
-
getReporter
public PrintWriter getReporter()
Description copied from interface:ResponseReturn a PrintWriter that can be used to render error messages, regardless of whether a stream or writer has already been acquired.- Specified by:
getReporterin interfaceResponse- Returns:
- Writer which can be used for error reports. If the response is not an error report returned using sendError or triggered by an unexpected exception thrown during the servlet processing (and only in that case), null will be returned if the response stream has already been used.
-
recycle
public void recycle()
Description copied from interface:ResponseRelease all object references, and initialize instance variables, in preparation for reuse of this object.
-
write
public void write(int b) throws IOException- Throws:
IOException
-
write
public void write(byte[] b) throws IOException- Throws:
IOException
-
write
public void write(byte[] b, int off, int len) throws IOException- Throws:
IOException
-
flushBuffer
public void flushBuffer() throws IOException- Specified by:
flushBufferin interfacejakarta.servlet.ServletResponse- Throws:
IOException
-
getBufferSize
public int getBufferSize()
- Specified by:
getBufferSizein interfacejakarta.servlet.ServletResponse
-
getCharacterEncoding
public String getCharacterEncoding()
- Specified by:
getCharacterEncodingin interfacejakarta.servlet.ServletResponse
-
setCharacterEncoding
public void setCharacterEncoding(String charEncoding)
- Specified by:
setCharacterEncodingin interfacejakarta.servlet.ServletResponse
-
getOutputStream
public jakarta.servlet.ServletOutputStream getOutputStream() throws IOException- Specified by:
getOutputStreamin interfacejakarta.servlet.ServletResponse- Throws:
IOException
-
getLocale
public Locale getLocale()
- Specified by:
getLocalein interfacejakarta.servlet.ServletResponse
-
getWriter
public PrintWriter getWriter() throws IOException
- Specified by:
getWriterin interfacejakarta.servlet.ServletResponse- Throws:
IOException
-
isCommitted
public boolean isCommitted()
- Specified by:
isCommittedin interfacejakarta.servlet.ServletResponse
-
reset
public void reset()
- Specified by:
resetin interfacejakarta.servlet.ServletResponse
-
resetBuffer
public void resetBuffer()
Description copied from interface:ResponseReset the data buffer but not any status or header information.- Specified by:
resetBufferin interfaceResponse- Specified by:
resetBufferin interfacejakarta.servlet.ServletResponse
-
resetBuffer
public void resetBuffer(boolean resetWriterStreamFlags)
Description copied from interface:ResponseReset the data buffer and the using Writer/Stream flags but not any status or header information.- Specified by:
resetBufferin interfaceResponse
-
setBufferSize
public void setBufferSize(int size)
- Specified by:
setBufferSizein interfacejakarta.servlet.ServletResponse
-
setContentLength
public void setContentLength(int length)
- Specified by:
setContentLengthin interfacejakarta.servlet.ServletResponse
-
setContentLengthLong
public void setContentLengthLong(long length)
- Specified by:
setContentLengthLongin interfacejakarta.servlet.ServletResponse
-
setContentType
public void setContentType(String type)
- Specified by:
setContentTypein interfacejakarta.servlet.ServletResponse
-
setLocale
public void setLocale(Locale locale)
- Specified by:
setLocalein interfacejakarta.servlet.ServletResponse
-
getHeader
public String getHeader(String name)
Description copied from interface:HttpResponseReturn the value for the specified header, ornullif this header has not been set. If more than one value was added for this name, only the first is returned; useHttpResponse.getHeaders(String)to retrieve all of them.- Specified by:
getHeaderin interfaceHttpResponse- Specified by:
getHeaderin interfacejakarta.servlet.http.HttpServletResponse- Parameters:
name- Header name to look up
-
getHeaderNames
public Collection<String> getHeaderNames()
- Specified by:
getHeaderNamesin interfaceHttpResponse- Specified by:
getHeaderNamesin interfacejakarta.servlet.http.HttpServletResponse- Returns:
- a (possibly empty)
Collectionof the names of the headers of this response
-
getHeaders
public Collection<String> getHeaders(String name)
- Specified by:
getHeadersin interfaceHttpResponse- Specified by:
getHeadersin interfacejakarta.servlet.http.HttpServletResponse- Parameters:
name- the name of the response header whose values to return- Returns:
- a (possibly empty)
Collectionof the values of the response header with the given name
-
addSessionCookieInternal
public void addSessionCookieInternal(jakarta.servlet.http.Cookie cookie)
Description copied from interface:HttpResponseSpecial method for adding a session cookie as we should be overriding any previous- Specified by:
addSessionCookieInternalin interfaceHttpResponse
-
getMessage
public String getMessage()
Description copied from interface:HttpResponseReturn the error message that was set withsendError()for this Response.- Specified by:
getMessagein interfaceHttpResponse
-
getStatus
public int getStatus()
Description copied from interface:HttpResponseReturn the HTTP status code associated with this Response.- Specified by:
getStatusin interfaceHttpResponse- Specified by:
getStatusin interfacejakarta.servlet.http.HttpServletResponse
-
reset
public void reset(int status, String message)Description copied from interface:HttpResponseReset this response, and specify the values for the HTTP status code and corresponding message.- Specified by:
resetin interfaceHttpResponse
-
addCookie
public void addCookie(jakarta.servlet.http.Cookie cookie)
- Specified by:
addCookiein interfacejakarta.servlet.http.HttpServletResponse
-
addDateHeader
public void addDateHeader(String name, long value)
- Specified by:
addDateHeaderin interfacejakarta.servlet.http.HttpServletResponse
-
addHeader
public void addHeader(String name, String value)
- Specified by:
addHeaderin interfacejakarta.servlet.http.HttpServletResponse
-
addIntHeader
public void addIntHeader(String name, int value)
- Specified by:
addIntHeaderin interfacejakarta.servlet.http.HttpServletResponse
-
containsHeader
public boolean containsHeader(String name)
- Specified by:
containsHeaderin interfacejakarta.servlet.http.HttpServletResponse
-
encodeRedirectURL
public String encodeRedirectURL(String url)
- Specified by:
encodeRedirectURLin interfacejakarta.servlet.http.HttpServletResponse
-
encodeURL
public String encodeURL(String url)
- Specified by:
encodeURLin interfacejakarta.servlet.http.HttpServletResponse
-
encode
public String encode(String url)
Description copied from interface:ResponseApply URL Encoding to the given URL without adding session identifier et al associated to this response.
-
sendAcknowledgement
public void sendAcknowledgement() throws IOExceptionDescription copied from interface:HttpResponseSend an acknowledgment of a request. An acknowledgment in this case is simply an HTTP response status line, i.e.HTTP/1.1 [STATUS] [REASON-PHRASE].- Specified by:
sendAcknowledgementin interfaceHttpResponse- Specified by:
sendAcknowledgementin interfaceResponse- Throws:
IOException- if an input/output error occurs
-
sendError
public void sendError(int status) throws IOException- Specified by:
sendErrorin interfacejakarta.servlet.http.HttpServletResponse- Throws:
IOException
-
sendError
public void sendError(int status, String message) throws IOException- Specified by:
sendErrorin interfacejakarta.servlet.http.HttpServletResponse- Throws:
IOException
-
sendRedirect
public void sendRedirect(String location) throws IOException
- Specified by:
sendRedirectin interfacejakarta.servlet.http.HttpServletResponse- Throws:
IOException
-
setDateHeader
public void setDateHeader(String name, long value)
- Specified by:
setDateHeaderin interfacejakarta.servlet.http.HttpServletResponse
-
setHeader
public void setHeader(String name, String value)
- Specified by:
setHeaderin interfacejakarta.servlet.http.HttpServletResponse
-
setIntHeader
public void setIntHeader(String name, int value)
- Specified by:
setIntHeaderin interfacejakarta.servlet.http.HttpServletResponse
-
setStatus
public void setStatus(int status)
- Specified by:
setStatusin interfacejakarta.servlet.http.HttpServletResponse
-
setStatus
public void setStatus(int status, String message)
-
setDetailMessage
public void setDetailMessage(String msg)
Description copied from interface:ResponseSets detail error message.- Specified by:
setDetailMessagein interfaceResponse- Parameters:
msg- detail error message
-
getDetailMessage
public String getDetailMessage()
Description copied from interface:ResponseGets detail error message.- Specified by:
getDetailMessagein interfaceResponse- Returns:
- the detail error message
-
-