org.mortbay.jetty.servlet

Class ServletHttpResponse

public class ServletHttpResponse extends Object implements HttpServletResponse

Servlet Response Wrapper. This class wraps a Jetty HTTP response as a 2.2 Servlet response. Note that this wrapper is not synchronized and if a response is to be operated on by multiple threads, then higher level synchronizations may be required.

Version: $Id: ServletHttpResponse.java,v 1.65 2006/04/04 22:28:05 gregwilkins Exp $

Author: Greg Wilkins (gregw)

Field Summary
static intDISABLED
static intNO_OUT
static intOUTPUTSTREAM_OUT
static intWRITER_OUT
Constructor Summary
ServletHttpResponse(ServletHttpRequest request, HttpResponse response)
Method Summary
voidaddCookie(Cookie cookie)
voidaddDateHeader(String name, long value)
voidaddHeader(String name, String value)
voidaddIntHeader(String name, int value)
booleancontainsHeader(String name)
StringencodeRedirectUrl(String url)
StringencodeRedirectURL(String url)
StringencodeUrl(String url)
StringencodeURL(String url)
voidflushBuffer()
intgetBufferSize()
StringgetCharacterEncoding()
StringgetContentType()
LocalegetLocale()
ServletOutputStreamgetOutputStream()
PrintWritergetWriter()
booleanisCommitted()
voidreset()
voidresetBuffer()
voidsendError(int status, String message)
voidsendError(int status)
voidsendRedirect(String url)
voidsetBufferSize(int size)
voidsetCharacterEncoding(String encoding)
voidsetContentLength(int len)
voidsetContentType(String contentType)
voidsetDateHeader(String name, long value)
voidsetHeader(String name, String value)
voidsetIntHeader(String name, int value)
voidsetLocale(Locale locale)
Sets the locale of the response, setting the headers (including the Content-Type's charset) as appropriate.
voidsetStatus(int status)
voidsetStatus(int status, String message)
StringtoString()
static ServletHttpResponseunwrap(ServletResponse response)
Unwrap a ServletResponse.

Field Detail

DISABLED

public static final int DISABLED

NO_OUT

public static final int NO_OUT

OUTPUTSTREAM_OUT

public static final int OUTPUTSTREAM_OUT

WRITER_OUT

public static final int WRITER_OUT

Constructor Detail

ServletHttpResponse

public ServletHttpResponse(ServletHttpRequest request, HttpResponse response)

Method Detail

addCookie

public void addCookie(Cookie cookie)

addDateHeader

public void addDateHeader(String name, long value)

addHeader

public void addHeader(String name, String value)

addIntHeader

public void addIntHeader(String name, int value)

containsHeader

public boolean containsHeader(String name)

encodeRedirectUrl

public String encodeRedirectUrl(String url)

Deprecated: As of version 2.1, use encodeRedirectURL(String url) instead

encodeRedirectURL

public String encodeRedirectURL(String url)

encodeUrl

public String encodeUrl(String url)

Deprecated: As of version 2.1, use encodeURL(String url) instead

encodeURL

public String encodeURL(String url)

flushBuffer

public void flushBuffer()

getBufferSize

public int getBufferSize()

getCharacterEncoding

public String getCharacterEncoding()

getContentType

public String getContentType()

getLocale

public Locale getLocale()

getOutputStream

public ServletOutputStream getOutputStream()

getWriter

public PrintWriter getWriter()

isCommitted

public boolean isCommitted()

reset

public void reset()

resetBuffer

public void resetBuffer()

sendError

public void sendError(int status, String message)

sendError

public void sendError(int status)

sendRedirect

public void sendRedirect(String url)

setBufferSize

public void setBufferSize(int size)

setCharacterEncoding

public void setCharacterEncoding(String encoding)

setContentLength

public void setContentLength(int len)

setContentType

public void setContentType(String contentType)

setDateHeader

public void setDateHeader(String name, long value)

setHeader

public void setHeader(String name, String value)

setIntHeader

public void setIntHeader(String name, int value)

setLocale

public void setLocale(Locale locale)
Sets the locale of the response, setting the headers (including the Content-Type's charset) as appropriate. This method should be called before a call to {@link #getWriter}. By default, the response locale is the default locale for the server.

Parameters: locale the Locale of the response

See Also: ServletHttpResponse

setStatus

public void setStatus(int status)

setStatus

public void setStatus(int status, String message)

Deprecated: As of version 2.1 of the Servlet spec. To set a status code use setStatus(int), to send an error with a description use sendError(int, String). Sets the status code and message for this response.

Parameters: status the status code message the status message

toString

public String toString()

unwrap

public static ServletHttpResponse unwrap(ServletResponse response)
Unwrap a ServletResponse.

Parameters: response

Returns: The core ServletHttpResponse which must be the underlying response object

See Also: ServletResponseWrapper HttpServletResponseWrapper

Copyright © 2004 Mortbay Consulting Pty. Ltd. All Rights Reserved.