Top Description Fields Methods
javax.portlet

public Interface ResourceResponse

extends MimeResponse
Known Direct Implementers
javax.portlet.filter.ResourceResponseWrapper

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

Modifier and TypeField and Description
public static final String
HTTP_STATUS_CODE

Constant for setting the HTTP status code via the setProperty method.

Inherited from javax.portlet.MimeResponse:
CACHE_SCOPEETAGEXPIRATION_CACHEMARKUP_HEAD_ELEMENTNAMESPACED_RESPONSEPRIVATE_SCOPEPUBLIC_SCOPEUSE_CACHED_CONTENT

Method Summary

Modifier and TypeMethod and Description
public <T extends PortletURL & ActionURL> T
createActionURL()

Redeclares javax.portlet.MimeResponse.createActionURL.

Creates an action URL targeting the portlet.
public ActionURL
createActionURL(MimeResponse.Copy
Specifies how current parameters are to be copied to the URL
option
)

Redeclares javax.portlet.MimeResponse.createActionURL.

Creates an action URL targeting the portlet.
public <T extends PortletURL & RenderURL> T
createRenderURL()

Redeclares javax.portlet.MimeResponse.createRenderURL.

Creates a render URL targeting the portlet.
public RenderURL
createRenderURL(MimeResponse.Copy
Specifies how current parameters are to be copied to the URL
option
)

Redeclares javax.portlet.MimeResponse.createRenderURL.

Creates a render URL targeting the portlet.
public ResourceURL
createResourceURL()

Redeclares javax.portlet.MimeResponse.createResourceURL.

Creates a resource URL targeting the portlet.
public int

Returns:

The HTTP status code
getStatus
()

Gets the current HTTP status code for the response.
public void
setCharacterEncoding(String
a String specifying only the character set defined by IANA Character Sets (http://www.iana.org/assignments/character-sets)
charset
)

Sets the character encoding (MIME charset) of the response being sent to the client, for example, to UTF-8.

public void
setContentLength(int
an integer specifying the length of the content being returned; sets the Content-Length header
len
)

Sets the length of the content body in the response.

public void
setContentLengthLong(long
a long specifying the length of the content being returned; sets the Content-Length header
len
)

Sets the length of the content body in the response.
public void
setLocale(Locale
the new locale of the response
loc
)

Sets the locale of the response, setting the headers (including the Content-Type's charset) as appropriate.

public void
setStatus(int
an integer specifying the status code for this request
sc
)

Sets the HTTP status code for this request.
Inherited from javax.portlet.MimeResponse:
flushBuffergetBufferSizegetCacheControlgetCharacterEncodinggetContentTypegetLocalegetPortletOutputStreamgetWriterisCommittedresetresetBuffersetBufferSizesetContentType

Field Detail

HTTP_STATUS_CODEback to summary
public static final String HTTP_STATUS_CODE

Constant for setting the HTTP status code via the setProperty method. Changing the HTTP status code after the response has been committed has no effect.

Method Detail

createActionURLback to summary
public <T extends PortletURL & ActionURL> T createActionURL()

Redeclares javax.portlet.MimeResponse.createActionURL.

Doc from javax.portlet.MimeResponse.createActionURL.

Creates an action URL targeting the portlet. Action URLs are used to create forms or links that, when triggered, update the render state in a non-idempotent manner.

If a request is triggered by the URL, it results in an action request.

The returned action URL will not contain any private render parameters per default not contain any parameters from the current request.

The returned URL can be further extended by adding portlet-specific action parameters, portlet mode, and window state. If no additional portlet mode, window state or security modifier is set on the URL, the values from the current render or resource request are preserved.

Public render parameters do not need to be explicitly added to the returned action URL, unless the public render parameter value is to be changed. Any public render parameters associated with the portlet will automatically be available during action request processing resulting from activation of the URL.

If a public render parameter value is set or removed on an action URL, then the public render parameter will be set to the new value or removed when the URL is activated.

The effect of this method is the same as calling createRenderURL(Copy) with the parameter set to PUBLIC.

Returns:T

a portlet action URL

Exceptions
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.
createActionURLback to summary
public ActionURL createActionURL(MimeResponse.Copy option)

Redeclares javax.portlet.MimeResponse.createActionURL.

Doc from javax.portlet.MimeResponse.createActionURL.

Creates an action URL targeting the portlet. Action URLs are used to create forms or links that, when triggered, update the render state in a non-idempotent manner.

If a request is triggered by the URL, it results in an action request.

The new action URL will contain render parameters from the current request as specified by the option parameter.

NONE
All public and private parameters are removed from the URL.
ALL
The public and private parameters governing the current request are added to the URL.
PUBLIC
Only public parameters governing the current request are added to the URL.

The returned URL can be further extended by adding action parameters, portlet mode, and window state. If no additional portlet mode, window state or security modifier is set on the URL, the values from the current render or resource request are preserved.

If a public render parameter value is set or removed on an action URL, then the public render parameter will be set to the new value or removed when the URL is activated.

Parameters
option:MimeResponse.Copy

Specifies how current parameters are to be copied to the URL

Returns:ActionURL

a portlet action URL

Exceptions
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.
Since
3.0
createRenderURLback to summary
public <T extends PortletURL & RenderURL> T createRenderURL()

Redeclares javax.portlet.MimeResponse.createRenderURL.

Doc from javax.portlet.MimeResponse.createRenderURL.

Creates a render URL targeting the portlet. Render URLs cause idempotent requests that move the portlet to a new view state, for example, to view a different page of data.

If a request is triggered by the URL, it results in a render request.

The returned render URL will not contain any private render parameters from the current request.

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

The returned URL can be further extended by adding portlet-specific render parameters, portlet mode, and window state. If no portlet mode, window state or security modifier is set on the URL, the values from the current render or resource request are preserved.

Public render parameters do not need to be explicitly added to the returned render URL, unless the public render parameter value is to be changed. Any public render parameters associated with the portlet will automatically be available during render request processing resulting from activation of the URL.

If a public render parameter value is set or removed on a render URL, then the public render parameter will be set to the new value or removed when the URL is activated.

The effect of this method is the same as calling createRenderURL(Copy) with the parameter set to PUBLIC.

Returns:T

a portlet render URL

Exceptions
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.
createRenderURLback to summary
public RenderURL createRenderURL(MimeResponse.Copy option)

Redeclares javax.portlet.MimeResponse.createRenderURL.

Doc from javax.portlet.MimeResponse.createRenderURL.

Creates a render URL targeting the portlet. Render URLs cause idempotent requests that move the portlet to a new view state, for example, to view a different page of data.

If a request is triggered by the URL, it results in a render request.

The new render URL will contain render parameters from the current request as specified by the option parameter.

NONE
All public and private parameters are removed from the URL.
ALL
The public and private parameters governing the current request are added to the URL.
PUBLIC
Only public parameters governing the current request are added to the URL.
The URL can be further extended by adding render parameters, portlet mode, and window state. If no additional portlet mode, window state or security modifier is set on the URL, the values from the current render or resource request are preserved.

If a public render parameter value is set or removed on a render URL, then the public render parameter will be set to the new value or removed when the URL is activated.

Parameters
option:MimeResponse.Copy

Specifies how current parameters are to be copied to the URL

Returns:RenderURL

a portlet render URL

Exceptions
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.
Since
3.0
createResourceURLback to summary
public ResourceURL createResourceURL()

Redeclares javax.portlet.MimeResponse.createResourceURL.

Doc from javax.portlet.MimeResponse.createResourceURL.

Creates a resource URL targeting the portlet. Resource URLs are used to trigger requests for content that applies to the current portlet view state.

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

The security settings can be changed for the URL. If the security settings are not explicitly set, the values governing the current request are preserved. The current render parameters, portlet mode, and window state are preserved depending on the cacheability setting for the returned resource URL.

If cacheability is set to PORTLET or PAGE, the values of the render parameters, portlet mode, and window state are preserved. Otherwise, they will not be preserved.

If allowed by the cacheability setting, public and private render parameters are added to the URL with their current values. The render parameter values cannot be changed on the URL.

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

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

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 by default contain the current cacheability setting of the parent resource. If no parent resource is available, PAGE is the default.

Returns:ResourceURL

a portlet resource URL

Exceptions
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.
getStatusback to summary
public int getStatus()

Gets the current HTTP status code for the response.
Returns:int

The HTTP status code

Since
3.0
See Also
javax.servlet.http.HttpServletResponse, javax.servlet.http.HttpServletResponse#getStatus
setCharacterEncodingback to summary
public void setCharacterEncoding(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:String

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

setContentLengthback to summary
public void setContentLength(int len)

Sets the length of the content body in the response.

This method has no effect if it is called after the response has been committed.

Parameters
len:int

an integer specifying the length of the content being returned; sets the Content-Length header

setContentLengthLongback to summary
public void setContentLengthLong(long len)

Sets the length of the content body in the response.

This method has no effect if it is called after the response has been committed.

Parameters
len:long

a long specifying the length of the content being returned; sets the Content-Length header

Since
3.0
setLocaleback to summary
public void setLocale(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.

This method has no effect if it is called after the response has been committed.

Parameters
loc:Locale

the new locale of the response

setStatusback to summary
public void setStatus(int sc)

Sets the HTTP status code for this request.

The status code should be a valid value as defined in IETF rfc2616 "Hypertext Transfer Protocol -- HTTP/1.1" . The status code constants "SC_*" defined in javax.servlet.http.HttpServletResponse may be used.

This method has no effect if it is called after the response has been committed.

Parameters
sc:int

an integer specifying the status code for this request

Since
3.0
See Also
javax.servlet.http.HttpServletResponse, javax.servlet.http.HttpServletResponse#setStatus