public interface MimeResponse extends PortletResponse
MimeResponse
defines the base interface to assist a
portlet in returning MIME content.Modifier and Type | Interface and Description |
---|---|
static class |
MimeResponse.Copy
Specifies processing when a URL is created.
|
Modifier and Type | Field and Description |
---|---|
static String |
CACHE_SCOPE
Property to set the cache scope for this response using the
setProperty method intended to be used in
forwarded or included servlets/JSPs. |
static String |
ETAG
Property to tell the portlet container the new ETag for this response
intended to be used in forwarded or included servlets/JSPs.
|
static String |
EXPIRATION_CACHE
Property to set the expiration time in seconds for this response using
the
setProperty method intended to be used in
forwarded or included servlets/JSPs. |
static String |
MARKUP_HEAD_ELEMENT
Property intended to be a hint to the portal application that the provided
DOM element should be added to the markup head section of the response to the
client.
|
static String |
NAMESPACED_RESPONSE
Property intended to be a hint to the portal application that the returned
content is completely namespaced.
|
static String |
PRIVATE_SCOPE
Private cache scope, indicating that the cache entry must not be shared
across users.
|
static String |
PUBLIC_SCOPE
Public cache scope, indicating that the cache entry can be shared across
users.
|
static String |
USE_CACHED_CONTENT
Property to tell the portlet container to use the cached markup
for the validation token provided in the request.
|
Modifier and Type | Method and Description |
---|---|
<T extends PortletURL & ActionURL> |
createActionURL()
Creates an action URL targeting the portlet.
|
ActionURL |
createActionURL(MimeResponse.Copy option)
Creates an action URL targeting the portlet.
|
<T extends PortletURL & RenderURL> |
createRenderURL()
Creates a render URL targeting the portlet.
|
RenderURL |
createRenderURL(MimeResponse.Copy option)
Creates a render URL targeting the portlet.
|
ResourceURL |
createResourceURL()
Creates a resource URL targeting the portlet.
|
void |
flushBuffer()
Forces any content in the buffer to be written to the underlying output stream.
|
int |
getBufferSize()
Returns the actual buffer size used for the response.
|
CacheControl |
getCacheControl()
Returns the cache control object allowing to set
specific cache settings valid for the markup
returned in this response.
|
String |
getCharacterEncoding()
Returns the name of the charset used for the MIME body sent in this
response.
|
String |
getContentType()
Returns the MIME type that can be used to contribute markup to the render
response.
|
Locale |
getLocale()
Returns the locale assigned to the response.
|
OutputStream |
getPortletOutputStream()
Returns a
OutputStream suitable for writing binary data in
the response. |
PrintWriter |
getWriter()
Returns a PrintWriter object that can send character text to the portal.
|
boolean |
isCommitted()
Returns a boolean indicating if the response has been committed.
|
void |
reset()
Clears any data that exists in the buffer as well as the properties set.
|
void |
resetBuffer()
Clears the content of the underlying buffer in the response without
clearing properties set.
|
void |
setBufferSize(int size)
Sets the preferred buffer size for the body of the response.
|
void |
setContentType(String type)
Sets
the MIME type for the response.
|
addProperty, addProperty, addProperty, createElement, encodeURL, getNamespace, getProperty, getPropertyNames, getPropertyValues, setProperty
static final String EXPIRATION_CACHE
setProperty
method intended to be used in
forwarded or included servlets/JSPs.
If the expiration value is set to 0
, caching is disabled for this
portlet; if the value is set to -1
, the cache does not expire.
A default can be defined in the portlet deployment descriptor
with the expiration-cache
tag, otherwise it is 0
.
Non-integer values are treated as 0
.
The value is "portlet.expiration-cache"
.
CacheControl
,
Constant Field Valuesstatic final String CACHE_SCOPE
setProperty
method intended to be used in
forwarded or included servlets/JSPs.
Predefined cache scopes are: PUBLIC_SCOPE
and PRIVATE_SCOPE
.
A default can be defined in the portlet deployment descriptor
with the cache-scope
tag, otherwise it is PRIVATE_SCOPE
.
Values that are not either PUBLIC_SCOPE
or PRIVATE_SCOPE
are treated as PRIVATE_SCOPE
.
The value is "portlet.cache-scope"
.
CacheControl
,
Constant Field Valuesstatic final String PUBLIC_SCOPE
"portlet.public-scope"
.static final String PRIVATE_SCOPE
"portlet.private-scope"
.static final String ETAG
This property needs to be set using the setProperty
method.
The value is "portlet.ETag "
.
CacheControl
,
Constant Field Valuesstatic final String USE_CACHED_CONTENT
setProperty
method with a non-null
value and is intended to be used in forwarded or included servlets/JSPs.
The value itself is not evaluated.
The value is "portlet.use-cached-content "
.
CacheControl
,
Constant Field Valuesstatic final String NAMESPACED_RESPONSE
This property needs to be set using the setProperty
method with a non-null
value. The value itself is not evaluated.
The value is "X-JAVAX-PORTLET-NAMESPACED-RESPONSE"
.
static final String MARKUP_HEAD_ELEMENT
Support for this property is optional and the portlet can verify if the
calling portal supports this property via the MARKUP_HEAD_ELEMENT_SUPPORT
property on the PortalContext
.
Even if the calling portal support this property delivery of the DOM element to the client cannot be guaranteed, e.g. due to possible security rules of the portal application or elements that conflict with the response of other portlets.
This property needs to be set using the
setProperty(String key,org.w3c.dom.Element element)
method.
The value is "javax.portlet.markup.head.element"
.
String getContentType()
If no content type was set previously using the setContentType(java.lang.String)
method this method returns null
.
null
if no
content type is setsetContentType(java.lang.String)
void setContentType(String type)
getWriter()
or
getPortletOutputStream()
.
If the content type is not set using this method, the preferred
content type as returned by PortletRequest.getResponseContentType()
is used.
Calling setContentType
after getWriter
or
getOutputStream
does not change the content type.
type
- the content MIME typeIllegalArgumentException
-
if the content type is invalid.
PortletRequest.getResponseContentTypes()
,
getContentType()
String getCharacterEncoding()
See RFC 2047 for more information about character encoding and MIME.
String
specifying the name of the charset, for
example, ISO-8859-1
PrintWriter getWriter() throws IOException
Before calling this method the content type of the render response should
be set using the setContentType(java.lang.String)
method.
Either this method or getPortletOutputStream()
may be called to
write the body, not both.
PrintWriter
object that can return character
data to the portalIOException
- if an input or output exception occurredIllegalStateException
- if the getPortletOutputStream
method has
been called on this response.setContentType(java.lang.String)
,
getPortletOutputStream()
Locale getLocale()
void setBufferSize(int size)
This method must be called before any response body content is written;
if content has been written, or the portlet container does not support
buffering, this method may throw an IllegalStateException
.
size
- the preferred buffer sizeIllegalStateException
- if this method is called after content has been written,
or the portlet container does not support bufferinggetBufferSize()
,
flushBuffer()
,
isCommitted()
,
reset()
int getBufferSize()
setBufferSize(int)
,
flushBuffer()
,
isCommitted()
,
reset()
void flushBuffer() throws IOException
IOException
- if an error occurred when writing the outputsetBufferSize(int)
,
getBufferSize()
,
isCommitted()
,
reset()
void resetBuffer()
IllegalStateException
.IllegalStateException
- if this method is called after response is committedsetBufferSize(int)
,
getBufferSize()
,
isCommitted()
,
reset()
boolean isCommitted()
setBufferSize(int)
,
getBufferSize()
,
flushBuffer()
,
reset()
void reset()
IllegalStateException
.IllegalStateException
- if the response has already been committedsetBufferSize(int)
,
getBufferSize()
,
flushBuffer()
,
isCommitted()
OutputStream getPortletOutputStream() throws IOException
OutputStream
suitable for writing binary data in
the response. The portlet container does not encode the binary data.
Before calling this method the content type of the render response must
be set using the setContentType(java.lang.String)
method.
Calling flush()
on the OutputStream commits the response.
Either this method or getWriter()
may be called to write the body,
not both.
OutputStream
for writing binary dataIllegalStateException
- if the getWriter
method has been called on
this response.IOException
- if an input or output exception occurredsetContentType(java.lang.String)
,
getWriter()
<T extends PortletURL & RenderURL> T createRenderURL()
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.
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.
RenderURL createRenderURL(MimeResponse.Copy option)
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.
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.
option
- Specifies how current parameters are to be copied to the URLMimeResponse.Copy
<T extends PortletURL & ActionURL> T createActionURL()
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.
ActionURL createActionURL(MimeResponse.Copy option)
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.
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.
option
- Specifies how current parameters are to be copied to the URLMimeResponse.Copy
ResourceURL createResourceURL()
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.
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.
CacheControl getCacheControl()
Java Portlet 3.0 API Specification. See the Copyright and License provided with this distribution. Use is subject to license terms.