com.vaadin.terminal
Interface WrappedResponse

All Superinterfaces:
Serializable
All Known Implementing Classes:
WrappedHttpServletResponse, WrappedPortletResponse

public interface WrappedResponse
extends Serializable

A generic response from the server, wrapping a more specific response type, e.g. HttpServletResponse or PortletResponse.

Since:
7.0

Method Summary
 DeploymentConfiguration getDeploymentConfiguration()
          Gets the deployment configuration for the context of this response.
 OutputStream getOutputStream()
          Returns a OutputStream for writing binary data in the response.
 PrintWriter getWriter()
          Returns a PrintWriter object that can send character text to the client.
 void sendError(int errorCode, String message)
          Sends an error response to the client using the specified status code and clears the buffer.
 void setCacheTime(long milliseconds)
          Sets cache time in milliseconds, -1 means no cache at all.
 void setContentType(String contentType)
          Sets the content type of this response.
 void setDateHeader(String name, long timestamp)
          Properly formats a timestamp as a date header.
 void setHeader(String name, String value)
          Sets the value of a generic response header.
 void setStatus(int statusCode)
          Sets the (http) status code for the response.
 

Method Detail

setStatus

void setStatus(int statusCode)
Sets the (http) status code for the response. If you want to include an error message along the status code, use sendError(int, String) instead.

Parameters:
statusCode - the status code to set
See Also:
HttpServletResponse.setStatus(int), ResourceResponse#HTTP_STATUS_CODE

setContentType

void setContentType(String contentType)
Sets the content type of this response. If the content type including a charset is set before getWriter() is invoked, the returned PrintWriter will automatically use the defined charset.

Parameters:
contentType - a string specifying the MIME type of the content
See Also:
ServletResponse.setContentType(String), MimeResponse#setContentType(String)

setHeader

void setHeader(String name,
               String value)
Sets the value of a generic response header. If the header had already been set, the new value overwrites the previous one.

Parameters:
name - the name of the header
value - the header value.
See Also:
HttpServletResponse.setHeader(String, String), PortletResponse#setProperty(String, String)

setDateHeader

void setDateHeader(String name,
                   long timestamp)
Properly formats a timestamp as a date header. If the header had already been set, the new value overwrites the previous one.

Parameters:
name - the name of the header
timestamp - the number of milliseconds since epoch
See Also:
HttpServletResponse.setDateHeader(String, long)

getOutputStream

OutputStream getOutputStream()
                             throws IOException
Returns a OutputStream for writing binary data in the response.

Either this method or getWriter() may be called to write the response, not both.

Returns:
a OutputStream for writing binary data
Throws:
IOException - if an input or output exception occurred
See Also:
getWriter(), ServletResponse.getOutputStream(), MimeResponse#getPortletOutputStream()

getWriter

PrintWriter getWriter()
                      throws IOException
Returns a PrintWriter object that can send character text to the client. The PrintWriter uses the character encoding defined using setContentType.

Either this method or getOutputStream() may be called to write the response, not both.

Returns:
a PrintWriter for writing character text
Throws:
IOException - if an input or output exception occurred
See Also:
getOutputStream(), ServletResponse.getWriter(), MimeResponse#getWriter()

setCacheTime

void setCacheTime(long milliseconds)
Sets cache time in milliseconds, -1 means no cache at all. All required headers related to caching in the response are set based on the time.

Parameters:
milliseconds - Cache time in milliseconds

sendError

void sendError(int errorCode,
               String message)
               throws IOException
Sends an error response to the client using the specified status code and clears the buffer. In some configurations, this can cause a predefined error page to be displayed.

Parameters:
errorCode - the HTTP status code
message - a message to accompany the error
Throws:
IOException - if an input or output exception occurs
See Also:
HttpServletResponse.sendError(int, String)

getDeploymentConfiguration

DeploymentConfiguration getDeploymentConfiguration()
Gets the deployment configuration for the context of this response.

Returns:
the deployment configuration
See Also:
DeploymentConfiguration


Copyright © 2000-2011 Vaadin Ltd. All Rights Reserved.