org.apache.coyote

Class Response

public final class Response extends Object

Response 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 Remy Maucherat

Field Summary
protected StringcharacterEncoding
protected booleancharsetSet
Has the charset been explicitly set.
protected booleancommited
Committed flag.
protected StringcontentLanguage
protected longcontentLength
protected StringcontentType
HTTP specific fields.
protected ExceptionerrorException
Holds request error exception.
protected StringerrorURI
Request error URI.
protected MimeHeadersheaders
Response headers.
ActionHookhook
Action hook.
protected Stringmessage
Status message.
protected Object[]notes
Notes.
protected OutputBufferoutputBuffer
Associated output buffer.
protected Requestreq
protected intstatus
Status code.
Constructor Summary
Response()
Method Summary
voidacknowledge()
voidaction(ActionCode actionCode, Object param)
voidaddHeader(String name, String value)
booleancontainsHeader(String name)
Warning: This method always returns false for Content-Type and Content-Length.
voiddoWrite(ByteChunk chunk)
Write a chunk of bytes.
voidfinish()
longgetBytesWritten()
StringgetCharacterEncoding()
StringgetContentLanguage()
Return the content language.
intgetContentLength()
longgetContentLengthLong()
StringgetContentType()
ExceptiongetErrorException()
Get the Exception that occurred during request processing.
StringgetErrorURI()
Get the request URI that caused the original error.
ActionHookgetHook()
LocalegetLocale()
StringgetMessage()
Get the status message.
MimeHeadersgetMimeHeaders()
ObjectgetNote(int pos)
OutputBuffergetOutputBuffer()
RequestgetRequest()
intgetStatus()
booleanisCommitted()
booleanisExceptionPresent()
voidrecycle()
voidreset()
voidsendHeaders()
Signal that we're done with the headers, and body will follow.
voidsetBytesWritten(long bytesWritten)
voidsetCharacterEncoding(String charset)
voidsetCommitted(boolean v)
voidsetContentLength(int contentLength)
voidsetContentLength(long contentLength)
voidsetContentType(String type)
Sets the content type.
voidsetErrorException(Exception ex)
Set the error Exception that occurred during request processing.
voidsetErrorURI(String uri)
Set request URI that caused an error during request processing.
voidsetHeader(String name, String value)
voidsetHook(ActionHook hook)
voidsetLocale(Locale locale)
Called explicitely by user to set the Content-Language and the default encoding
voidsetMessage(String message)
Set the status message.
voidsetNote(int pos, Object value)
voidsetOutputBuffer(OutputBuffer outputBuffer)
voidsetRequest(Request req)
voidsetStatus(int status)
Set the response status

Field Detail

characterEncoding

protected String characterEncoding

charsetSet

protected boolean charsetSet
Has the charset been explicitly set.

commited

protected boolean commited
Committed flag.

contentLanguage

protected String contentLanguage

contentLength

protected long contentLength

contentType

protected String contentType
HTTP specific fields.

errorException

protected Exception errorException
Holds request error exception.

errorURI

protected String errorURI
Request error URI.

headers

protected MimeHeaders headers
Response headers.

hook

public ActionHook hook
Action hook.

message

protected String message
Status message.

notes

protected Object[] notes
Notes.

outputBuffer

protected OutputBuffer outputBuffer
Associated output buffer.

req

protected Request req

status

protected int status
Status code.

Constructor Detail

Response

public Response()

Method Detail

acknowledge

public void acknowledge()

action

public void action(ActionCode actionCode, Object param)

addHeader

public void addHeader(String name, String value)

containsHeader

public boolean containsHeader(String name)
Warning: This method always returns false for Content-Type and Content-Length.

doWrite

public void doWrite(ByteChunk chunk)
Write a chunk of bytes.

finish

public void finish()

getBytesWritten

public long getBytesWritten()

getCharacterEncoding

public String getCharacterEncoding()

getContentLanguage

public String getContentLanguage()
Return the content language.

getContentLength

public int getContentLength()

getContentLengthLong

public long getContentLengthLong()

getContentType

public String getContentType()

getErrorException

public Exception getErrorException()
Get the Exception that occurred during request processing.

getErrorURI

public String getErrorURI()
Get the request URI that caused the original error.

getHook

public ActionHook getHook()

getLocale

public Locale getLocale()

getMessage

public String getMessage()
Get the status message.

getMimeHeaders

public MimeHeaders getMimeHeaders()

getNote

public final Object getNote(int pos)

getOutputBuffer

public OutputBuffer getOutputBuffer()

getRequest

public Request getRequest()

getStatus

public int getStatus()

isCommitted

public boolean isCommitted()

isExceptionPresent

public boolean isExceptionPresent()

recycle

public void recycle()

reset

public void reset()

sendHeaders

public 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.

setBytesWritten

public void setBytesWritten(long bytesWritten)

setCharacterEncoding

public void setCharacterEncoding(String charset)

setCommitted

public void setCommitted(boolean v)

setContentLength

public void setContentLength(int contentLength)

setContentLength

public void setContentLength(long contentLength)

setContentType

public void setContentType(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

setErrorException

public void setErrorException(Exception ex)
Set the error Exception that occurred during request processing.

setErrorURI

public void setErrorURI(String uri)
Set request URI that caused an error during request processing.

setHeader

public void setHeader(String name, String value)

setHook

public void setHook(ActionHook hook)

setLocale

public void setLocale(Locale locale)
Called explicitely by user to set the Content-Language and the default encoding

setMessage

public void setMessage(String message)
Set the status message.

setNote

public final void setNote(int pos, Object value)

setOutputBuffer

public void setOutputBuffer(OutputBuffer outputBuffer)

setRequest

public void setRequest(Request req)

setStatus

public void setStatus(int status)
Set the response status
Copyright © 2000-2011 Apache Software Foundation. All Rights Reserved.