javax.portlet
Interface ResourceResponse

All Superinterfaces:
MimeResponse, PortletResponse
All Known Implementing Classes:
ResourceResponseWrapper

public interface ResourceResponse
extends MimeResponse

The ResourceResponse defines an object to assist a portlet for rendering a resource.

The difference between the RenderResponse is that for the ResourceResponse the output of this response is delivered directly to the client without any additional markup added by the portal. It is therefore allowed for the portlet to return binary content in this response.

A portlet can set HTTP headers for the response via the setProperty or addProperty call in the ResourceResponse. To be successfully transmitted back to the client, headers must be set before the response is committed. Headers set after the response is committed will be ignored by the portlet container.

The portlet container creates a ResourceResponse object and passes it as argument to the portlet's serveResource method.

Since:
2.0
See Also:
ResourceServingPortlet, MimeResponse

Field Summary
static java.lang.String HTTP_STATUS_CODE
          Constant for setting the HTTP status code via the setProperty method.
 
Fields inherited from interface javax.portlet.MimeResponse
CACHE_SCOPE, ETAG, EXPIRATION_CACHE, MARKUP_HEAD_ELEMENT, NAMESPACED_RESPONSE, PRIVATE_SCOPE, PUBLIC_SCOPE, USE_CACHED_CONTENT
 
Method Summary
 PortletURL createActionURL()
          Creates a portlet URL targeting the portlet.
 PortletURL createRenderURL()
          Creates a portlet URL targeting the portlet.
 ResourceURL createResourceURL()
          Creates a portlet URL targeting the portlet.
 void setCharacterEncoding(java.lang.String charset)
          Sets the character encoding (MIME charset) of the response being sent to the client, for example, to UTF-8.
 void setContentLength(int len)
          Sets the length of the content body in the response.
 void setLocale(java.util.Locale loc)
          Sets the locale of the response, setting the headers (including the Content-Type's charset) as appropriate.
 
Methods inherited from interface javax.portlet.MimeResponse
flushBuffer, getBufferSize, getCacheControl, getCharacterEncoding, getContentType, getLocale, getPortletOutputStream, getWriter, isCommitted, reset, resetBuffer, setBufferSize, setContentType
 
Methods inherited from interface javax.portlet.PortletResponse
addProperty, addProperty, addProperty, createElement, encodeURL, getNamespace, setProperty
 

Field Detail

HTTP_STATUS_CODE

static final java.lang.String HTTP_STATUS_CODE
Constant for setting the HTTP status code via the setProperty method.

See Also:
Constant Field Values
Method Detail

setLocale

void setLocale(java.util.Locale loc)
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 getWriter(). By default, the response locale is the default locale provided by the portlet container.

Parameters:
loc - the new locale of the response

setCharacterEncoding

void setCharacterEncoding(java.lang.String charset)
Sets the character encoding (MIME charset) of the response being sent to the client, for example, to UTF-8. If the character encoding has already been set by either the portlet container, setContentType(java.lang.String) or setLocale(java.util.Locale), this method overrides it. Calling setContentType(java.lang.String) with the String of text/html and calling this method with the String of UTF-8 is equivalent with calling setContentType with the String of text/html; charset=UTF-8.

This method can be called repeatedly to change the character encoding. This method has no effect if it is called after getWriter has been called or after the response has been committed.

Parameters:
charset - a String specifying only the character set defined by IANA Character Sets (http://www.iana.org/assignments/character-sets)

setContentLength

void setContentLength(int len)
Sets the length of the content body in the response.

Parameters:
len - an integer specifying the length of the content being returned

createRenderURL

PortletURL createRenderURL()
Description copied from interface: MimeResponse
Creates a portlet URL targeting the portlet. If no portlet mode, window state or security modifier is set in the PortletURL the current values are preserved. If a request is triggered by the PortletURL, it results in a render request.

The returned URL can be further extended by adding portlet-specific parameters and portlet modes and window states.

The created URL will per default not contain any parameters of the current render request.

Specified by:
createRenderURL in interface MimeResponse
Returns:
a portlet render URL
Throws:
java.lang.IllegalStateException - if the cacheability level of the resource URL triggering this serveResource call is not PAGE and thus does not allow for creating render URLs.

createActionURL

PortletURL createActionURL()
Description copied from interface: MimeResponse
Creates a portlet URL targeting the portlet. If no portlet mode, window state or security modifier is set in the PortletURL the current values are preserved. If a request is triggered by the PortletURL, it results in an action request.

The returned URL can be further extended by adding portlet-specific parameters and portlet modes and window states.

The created URL will per default not contain any parameters of the current render request.

Specified by:
createActionURL in interface MimeResponse
Returns:
a portlet action URL
Throws:
java.lang.IllegalStateException - if the cacheability level of the resource URL triggering this serveResource call is not PAGE and thus does not allow for creating action URLs.

createResourceURL

ResourceURL createResourceURL()
Description copied from interface: MimeResponse
Creates a portlet URL targeting the portlet. If no security modifier is set in the PortletURL the current values are preserved. The current render parameters, portlet mode and window state are preserved.

If a request is triggered by the PortletURL, it results in a serve resource request of the ResourceServingPortlet interface.

The returned URL can be further extended by adding portlet-specific parameters .

The created URL will per default contain the current cacheability setting of the parent resource. If no parent resource is available, PAGE is the default.

Specified by:
createResourceURL in interface MimeResponse
Returns:
a portlet resource URL
Throws:
java.lang.IllegalStateException - if the cacheability level of the resource URL triggering this serveResource call, or one of the parent calls, have defined a stricter cachability level.