Package org.apache.coyote
Class Response
- java.lang.Object
- 
- org.apache.coyote.Response
 
- 
 public final class Response extends java.lang.ObjectResponse object.- Author:
- James Duncan Davidson [duncan@eng.sun.com], Jason Hunter [jch@eng.sun.com], James Todd [gonzo@eng.sun.com], Harish Prabandham, Hans Bergsten [hans@gefionsoftware.com], Remy Maucherat
 
- 
- 
Constructor SummaryConstructors Constructor Description Response()
 - 
Method SummaryAll Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description voidaction(ActionCode actionCode, java.lang.Object param)voidaddHeader(java.lang.String name, java.lang.String value)voidaddHeader(java.lang.String name, java.lang.String value, java.nio.charset.Charset charset)booleancheckRegisterForWrite()booleancontainsHeader(java.lang.String name)Does the response contain the given header.voiddoWrite(java.nio.ByteBuffer chunk)Write a chunk of bytes.voiddoWrite(ByteChunk chunk)Deprecated.Unused.longgetBytesWritten(boolean flush)Bytes written to socket - i.e. after compression, chunking, etc.java.lang.StringgetCharacterEncoding()java.nio.charset.CharsetgetCharset()longgetCommitTime()Return the time the response was committed (based on System.currentTimeMillis).java.lang.StringgetContentLanguage()Return the content language.intgetContentLength()longgetContentLengthLong()java.lang.StringgetContentType()longgetContentWritten()Bytes written by application - i.e. before compression, chunking, etc.java.lang.ExceptiongetErrorException()Get the Exception that occurred during the writing of the response.java.util.LocalegetLocale()java.lang.StringgetMessage()Get the status message.MimeHeadersgetMimeHeaders()java.lang.ObjectgetNote(int pos)RequestgetRequest()intgetStatus()WriteListenergetWriteListener()booleanisCommitted()booleanisError()Error flag accessor.booleanisErrorReportRequired()booleanisExceptionPresent()booleanisReady()voidonWritePossible()voidrecycle()voidreset()voidsendHeaders()Signal that we're done with the headers, and body will follow.voidsetCharacterEncoding(java.lang.String characterEncoding)Overrides the character encoding used in the body of the response.voidsetCommitted(boolean v)voidsetContentLength(long contentLength)voidsetContentType(java.lang.String type)Sets the content type.voidsetContentTypeNoCharset(java.lang.String type)booleansetError()Set the error flag.voidsetErrorException(java.lang.Exception ex)Set the error Exception that occurred during the writing of the response processing.booleansetErrorReported()voidsetHeader(java.lang.String name, java.lang.String value)protected voidsetHook(ActionHook hook)voidsetLocale(java.util.Locale locale)Called explicitly by user to set the Content-Language and the default encoding.voidsetMessage(java.lang.String message)Set the status message.voidsetNote(int pos, java.lang.Object value)voidsetOutputBuffer(OutputBuffer outputBuffer)voidsetRequest(Request req)voidsetStatus(int status)Set the response status.voidsetWriteListener(WriteListener listener)
 
- 
- 
- 
Method Detail- 
getRequestpublic Request getRequest() 
 - 
setRequestpublic void setRequest(Request req) 
 - 
setOutputBufferpublic void setOutputBuffer(OutputBuffer outputBuffer) 
 - 
getMimeHeaderspublic MimeHeaders getMimeHeaders() 
 - 
setHookprotected void setHook(ActionHook hook) 
 - 
setNotepublic final void setNote(int pos, java.lang.Object value)
 - 
getNotepublic final java.lang.Object getNote(int pos) 
 - 
actionpublic void action(ActionCode actionCode, java.lang.Object param) 
 - 
getStatuspublic int getStatus() 
 - 
setStatuspublic void setStatus(int status) Set the response status.- Parameters:
- status- The status value to set
 
 - 
getMessagepublic java.lang.String getMessage() Get the status message.- Returns:
- The message associated with the current status
 
 - 
setMessagepublic void setMessage(java.lang.String message) Set the status message.- Parameters:
- message- The status message to set
 
 - 
isCommittedpublic boolean isCommitted() 
 - 
setCommittedpublic void setCommitted(boolean v) 
 - 
getCommitTimepublic long getCommitTime() Return the time the response was committed (based on System.currentTimeMillis).- Returns:
- the time the response was committed
 
 - 
setErrorExceptionpublic void setErrorException(java.lang.Exception ex) Set the error Exception that occurred during the writing of the response processing.- Parameters:
- ex- The exception that occurred
 
 - 
getErrorExceptionpublic java.lang.Exception getErrorException() Get the Exception that occurred during the writing of the response.- Returns:
- The exception that occurred
 
 - 
isExceptionPresentpublic boolean isExceptionPresent() 
 - 
setErrorpublic boolean setError() Set the error flag.- Returns:
- falseif the error flag was already set
 
 - 
isErrorpublic boolean isError() Error flag accessor.- Returns:
- trueif the response has encountered an error
 
 - 
isErrorReportRequiredpublic boolean isErrorReportRequired() 
 - 
setErrorReportedpublic boolean setErrorReported() 
 - 
resetpublic void reset() throws java.lang.IllegalStateException- Throws:
- java.lang.IllegalStateException
 
 - 
containsHeaderpublic boolean containsHeader(java.lang.String name) Does the response contain the given header.
 Warning: This method always returnsfalsefor Content-Type and Content-Length.- Parameters:
- name- The name of the header of interest
- Returns:
- trueif the response contains the header.
 
 - 
setHeaderpublic void setHeader(java.lang.String name, java.lang.String value)
 - 
addHeaderpublic void addHeader(java.lang.String name, java.lang.String value)
 - 
addHeaderpublic void addHeader(java.lang.String name, java.lang.String value, java.nio.charset.Charset charset)
 - 
sendHeaderspublic void sendHeaders() Signal that we're done with the headers, and body will follow. Any implementation needs to notify ContextManager, to allow interceptors to fix headers.
 - 
getLocalepublic java.util.Locale getLocale() 
 - 
setLocalepublic void setLocale(java.util.Locale locale) Called explicitly by user to set the Content-Language and the default encoding.- Parameters:
- locale- The locale to use for this response
 
 - 
getContentLanguagepublic java.lang.String getContentLanguage() Return the content language.- Returns:
- The language code for the language currently associated with this response
 
 - 
setCharacterEncodingpublic void setCharacterEncoding(java.lang.String characterEncoding) Overrides the character encoding used in the body of the response. This method must be called prior to writing output using getWriter().- Parameters:
- characterEncoding- The name of character encoding.
 
 - 
getCharsetpublic java.nio.charset.Charset getCharset() 
 - 
getCharacterEncodingpublic java.lang.String getCharacterEncoding() - Returns:
- The name of the current encoding
 
 - 
setContentTypepublic void setContentType(java.lang.String type) Sets the content type. This method must preserve any response charset that may already have been set via a call to response.setContentType(), response.setLocale(), or response.setCharacterEncoding().- Parameters:
- type- the content type
 
 - 
setContentTypeNoCharsetpublic void setContentTypeNoCharset(java.lang.String type) 
 - 
getContentTypepublic java.lang.String getContentType() 
 - 
setContentLengthpublic void setContentLength(long contentLength) 
 - 
getContentLengthpublic int getContentLength() 
 - 
getContentLengthLongpublic long getContentLengthLong() 
 - 
doWrite@Deprecated public void doWrite(ByteChunk chunk) throws java.io.IOException Deprecated.Unused. Will be removed in Tomcat 9. UsedoWrite(ByteBuffer)Write a chunk of bytes.- Parameters:
- chunk- The bytes to write
- Throws:
- java.io.IOException- If an I/O error occurs during the write
 
 - 
doWritepublic void doWrite(java.nio.ByteBuffer chunk) throws java.io.IOExceptionWrite a chunk of bytes.- Parameters:
- chunk- The ByteBuffer to write
- Throws:
- java.io.IOException- If an I/O error occurs during the write
 
 - 
recyclepublic void recycle() 
 - 
getContentWrittenpublic long getContentWritten() Bytes written by application - i.e. before compression, chunking, etc.- Returns:
- The total number of bytes written to the response by the application. This will not be the number of bytes written to the network which may be more or less than this value.
 
 - 
getBytesWrittenpublic long getBytesWritten(boolean flush) Bytes written to socket - i.e. after compression, chunking, etc.- Parameters:
- flush- Should any remaining bytes be flushed before returning the total? If- falsebytes remaining in the buffer will not be included in the returned value
- Returns:
- The total number of bytes written to the socket for this response
 
 - 
getWriteListenerpublic WriteListener getWriteListener() 
 - 
setWriteListenerpublic void setWriteListener(WriteListener listener) 
 - 
isReadypublic boolean isReady() 
 - 
checkRegisterForWritepublic boolean checkRegisterForWrite() 
 - 
onWritePossiblepublic void onWritePossible() throws java.io.IOException- Throws:
- java.io.IOException
 
 
- 
 
-