org.apache.tapestry.web
Class ServletWebResponse

java.lang.Object
  extended byorg.apache.tapestry.web.ServletWebResponse
All Implemented Interfaces:
WebResponse

public class ServletWebResponse
extends java.lang.Object
implements WebResponse

Adapts HttpServletResponse as WebResponse.

Since:
4.0
Author:
Howard M. Lewis Ship

Constructor Summary
ServletWebResponse(javax.servlet.http.HttpServletResponse response)
           
 
Method Summary
 java.lang.String encodeURL(java.lang.String url)
          Encodes a URL, which adds information to the URL needed to ensure that the request triggered by the URL will be associated with the current session (if any).
 java.lang.String getNamespace()
          Returns a value to be prefixed or suffixed with any client-side JavaScript elements (variables and function names) to ensure that they are unique with the context of the entire page.
 java.io.OutputStream getOutputStream(ContentType contentType)
          Returns a output stream to which output should be sent.
 java.io.PrintWriter getPrintWriter(ContentType contentType)
          Returns a PrintWriter to which output should be sent.
 void reset()
          Resets any buffered content.
 void sendError(int statusCode, java.lang.String message)
          Sends an error response.
 void setContentLength(int length)
           
 void setDateHeader(java.lang.String name, long date)
          Sets a response header as a date.
 void setHeader(java.lang.String name, java.lang.String value)
          Sets a response header as a string.
 void setIntHeader(java.lang.String name, int value)
          Sets a response header with the given name and integer value.
 void setStatus(int status)
          Sets the status code for this response.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ServletWebResponse

public ServletWebResponse(javax.servlet.http.HttpServletResponse response)
Method Detail

getOutputStream

public java.io.OutputStream getOutputStream(ContentType contentType)
Description copied from interface: WebResponse
Returns a output stream to which output should be sent. This method should only be invoked once on a response.

Specified by:
getOutputStream in interface WebResponse
Returns:
the output stream, configured for the given type.

getPrintWriter

public java.io.PrintWriter getPrintWriter(ContentType contentType)
                                   throws java.io.IOException
Description copied from interface: WebResponse
Returns a PrintWriter to which output should be sent. This method should be invoked once on a response. A second call is expected to be so that an exception page can be rendered, and the underlying request data is reset.

Specified by:
getPrintWriter in interface WebResponse
Throws:
java.io.IOException

encodeURL

public java.lang.String encodeURL(java.lang.String url)
Description copied from interface: WebResponse
Encodes a URL, which adds information to the URL needed to ensure that the request triggered by the URL will be associated with the current session (if any). In most cases, the string is returned unchanged.

Specified by:
encodeURL in interface WebResponse

reset

public void reset()
Description copied from interface: WebResponse
Resets any buffered content. This may be used after an error to radically change what the output will be.

Specified by:
reset in interface WebResponse

setContentLength

public void setContentLength(int length)
Specified by:
setContentLength in interface WebResponse

getNamespace

public java.lang.String getNamespace()
Description copied from interface: WebResponse
Returns a value to be prefixed or suffixed with any client-side JavaScript elements (variables and function names) to ensure that they are unique with the context of the entire page. For servlets, this is the empty string.

Specified by:
getNamespace in interface WebResponse

setDateHeader

public void setDateHeader(java.lang.String name,
                          long date)
Description copied from interface: WebResponse
Sets a response header as a date.

Specified by:
setDateHeader in interface WebResponse
Parameters:
name - the name of the header to set
date - the date value to set, in milliseconds since the epoch

setStatus

public void setStatus(int status)
Description copied from interface: WebResponse
Sets the status code for this response.

Specified by:
setStatus in interface WebResponse

setHeader

public void setHeader(java.lang.String name,
                      java.lang.String value)
Description copied from interface: WebResponse
Sets a response header as a string.

Specified by:
setHeader in interface WebResponse
Parameters:
name - the name of the header to set
value - the value for the named header

setIntHeader

public void setIntHeader(java.lang.String name,
                         int value)
Description copied from interface: WebResponse
Sets a response header with the given name and integer value.

Specified by:
setIntHeader in interface WebResponse
Parameters:
name - the name of the header to set
value - the value for the named header

sendError

public void sendError(int statusCode,
                      java.lang.String message)
               throws java.io.IOException
Description copied from interface: WebResponse
Sends an error response.

Specified by:
sendError in interface WebResponse
Throws:
java.io.IOException