Top Description Fields Methods
javax.portlet

public Interface ResourceRequest

extends ClientDataRequest
Known Direct Implementers
javax.portlet.filter.ResourceRequestWrapper
Imports
javax.servlet.DispatcherType

The ResourceRequest interface represents the request send to the portlet for rendering resources. It extends the ClientDataRequest interface and provides resource request information to portlets.

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

The ResourceRequest is provided with the current portlet mode, window state, and render parameters that the portlet can access via the PortletResourceRequest with getPortletMode and, getWindowState, or one of the getParameter methods. ResourceURLs cannot change the current portlet mode, window state or render parameters. Parameters set on a resource URL are not render parameters but parameters for serving this resource and will last only for only this the current serveResource request.
If a parameter is set that has the same name as a render parameter that this resource URL contains, the render parameter must be the last entry in the parameter value array.

Since
2.0
See Also
ClientDataRequest, ResourceServingPortlet

Field Summary

Modifier and TypeField and Description
public static final String
ETAG

This property is set by the container if the container has a cached response for the given validation tag.

Method Summary

Modifier and TypeMethod and Description
public String

Returns:

the cache level of this resource request.
getCacheability
()

Returns the cache level of this resource request.

public DispatcherType

Returns:

the dispatcher type of this request
getDispatcherType
()

Gets the dispatcher type of this request.
public String

Returns:

the validation tag if the portlet container has a cached response for this validation tag, or null if no cached response exists.
getETag
()

Returns the validation tag if the portlet container has a cached response for this validation tag, or null if no cached response exists.

public PortletAsyncContext

Returns:

the AsyncContext (re)initialized by the most recent startAsync method invocation
getPortletAsyncContext
()

Gets the AsyncContext that was created or reinitialized by the most recent invocation of startAsync() or startAsync(ResourceRequest,ResourceResponse) on this request.
public PortletMode

Returns:

the portlet mode. The portlet mode UNDEFINED will be returned if the cache level is set to ResourceURL.FULL.
getPortletMode
()

Redeclares javax.portlet.RenderState.getPortletMode.

Returns the current portlet mode of the portlet.
public Map<String, String[]>

Returns:

an immutable Map containing private parameter names as keys and private parameter values as map values, or an empty Map if no private parameters exist. The keys in the parameter map are of type String. The values in the parameter map are of type String array (String[]).
getPrivateRenderParameterMap
()

Deprecated As of version 3.0. Use PortletRequest#getRenderParameters() instead.
Returns a Map of the private render parameters of this request.
public String

Returns:

the resource ID set on the ResourceURL,or null if no resource ID was set on the URL.
getResourceID
()

Returns the resource ID set on the ResourceURL or null if no resource ID was set on the URL.

public ResourceParameters

Returns:

an immutable ResourceParameters object representing the resource parameters
getResourceParameters
()

Gets the resource parameters set for this request.
public String

Returns:

preferred content type of the response
getResponseContentType
()

Redeclares javax.portlet.PortletRequest.getResponseContentType.

Returns the portal preferred content type for the response.
public Enumeration<String>

Returns:

ordered list of content types for the response
getResponseContentTypes
()

Redeclares javax.portlet.PortletRequest.getResponseContentTypes.

Gets a list of content types which the portal accepts for the response.
public WindowState

Returns:

the window state. The window state UNDEFINED will be returned if the cache level is set to ResourceURL.FULL.
getWindowState
()

Redeclares javax.portlet.RenderState.getWindowState.

Returns the current window state of the portlet.
public boolean

Returns:

true if asynchronous mode has been started
isAsyncStarted
()

Checks if this request has been put into asynchronous mode.
public boolean

Returns:

true if this request supports asynchronous operation
isAsyncSupported
()

Checks if this request supports asynchronous operation.
public PortletAsyncContext

Returns:

the (re)initialized AsyncContext
startPortletAsync
()

Puts this request into asynchronous mode and initializes the AsyncContext object.
public PortletAsyncContext

Returns:

the (re)initialized AsyncContext
startPortletAsync
(ResourceRequest request, ResourceResponse response)

Puts this request into asynchronous mode and initializes the AsyncContext object.
Inherited from javax.portlet.ClientDataRequest:
getCharacterEncodinggetContentLengthgetContentLengthLonggetContentTypegetMethodgetPartgetPartsgetPortletInputStreamgetReadersetCharacterEncoding

Field Detail

ETAGback to summary
public static final String ETAG

This property is set by the container if the container has a cached response for the given validation tag. The property can be retrieved using the getProperty method.

The value is "portlet.ETag ".

Method Detail

getCacheabilityback to summary
public String getCacheability()

Returns the cache level of this resource request.

Possible return values are: ResourceURL.FULL, ResourceURL.PORTLET or ResourceURL.PAGE.

Returns:String

the cache level of this resource request.

getDispatcherTypeback to summary
public DispatcherType getDispatcherType()

Gets the dispatcher type of this request.

The initial dispatcher type of a request is defined as DispatcherType.REQUEST. The dispatcher type of a request dispatched via a RequestDispatcher is given as DispatcherType.FORWARD or DispatcherType.INCLUDE, while the dispatcher type of an asynchronous request dispatched via one of the AsyncContext#dispatch methods is given as DispatcherType.ASYNC.

Returns:DispatcherType

the dispatcher type of this request

Since
3.0
See Also
javax.servlet.DispatcherType
getETagback to summary
public String getETag()

Returns the validation tag if the portlet container has a cached response for this validation tag, or null if no cached response exists.

This call returns the same value as ResourceRequest.getProperty(ResourceRequest.ETAG).

Returns:String

the validation tag if the portlet container has a cached response for this validation tag, or null if no cached response exists.

getPortletAsyncContextback to summary
public PortletAsyncContext getPortletAsyncContext()

Gets the AsyncContext that was created or reinitialized by the most recent invocation of startAsync() or startAsync(ResourceRequest,ResourceResponse) on this request.
Returns:PortletAsyncContext

the AsyncContext (re)initialized by the most recent startAsync method invocation

Exceptions
IllegalStateException:
if this request is within the scope of a filter or servlet that does not support asynchronous operations (that is, isAsyncSupported() returns false), or if asynchronous processing has not yet been started.
Since
3.0
See Also
javax.servlet.ServletRequest#startAsync(), javax.servlet.AsyncContext
getPortletModeback to summary
public PortletMode getPortletMode()

Redeclares javax.portlet.RenderState.getPortletMode.

Returns the current portlet mode of the portlet.

If called during a request where the cache level is set to ResourceURL.FULL, the portlet mode will not be available.

Returns:PortletMode

the portlet mode. The portlet mode UNDEFINED will be returned if the cache level is set to ResourceURL.FULL.

Since
3.0
getPrivateRenderParameterMapback to summary
public Map<String, String[]> getPrivateRenderParameterMap()

Deprecated

As of version 3.0. Use PortletRequest#getRenderParameters() instead.

Returns a Map of the private render parameters of this request. Private parameters are not shared with other portlets or components. The returned parameters are "x-www-form-urlencoded" decoded.

The parameters returned do not include the resource parameters that the portlet may have set on the resource URL triggering this serveResource call.

The values in the returned Map are from type String array (String[]).

If no private parameters exist this method returns an empty Map.

Returns:Map<String, String[]>

an immutable Map containing private parameter names as keys and private parameter values as map values, or an empty Map if no private parameters exist. The keys in the parameter map are of type String. The values in the parameter map are of type String array (String[]).

Annotations
@Deprecated
getResourceIDback to summary
public String getResourceID()

Returns the resource ID set on the ResourceURL or null if no resource ID was set on the URL.

Returns:String

the resource ID set on the ResourceURL,or null if no resource ID was set on the URL.

getResourceParametersback to summary
public ResourceParameters getResourceParameters()

Gets the resource parameters set for this request.

Resource parameters are additional portlet parameters added to the URL triggering the request that extend the state information provided by the render parameters.

PortletParameters provides a description of the parameter concept.

Returns:ResourceParameters

an immutable ResourceParameters object representing the resource parameters

Since
3.0
See Also
PortletParameters, MutableResourceParameters, ResourceURL
getResponseContentTypeback to summary
public String getResponseContentType()

Redeclares javax.portlet.PortletRequest.getResponseContentType.

Returns the portal preferred content type for the response.

The returned content type should be based on the HTTP Accept header provided by the client.

Returns:String

preferred content type of the response

getResponseContentTypesback to summary
public Enumeration<String> getResponseContentTypes()

Redeclares javax.portlet.PortletRequest.getResponseContentTypes.

Gets a list of content types which the portal accepts for the response. This list is ordered with the most preferable types listed first.

The returned content types should be based on the HTTP Accept header provided by the client.

Returns:Enumeration<String>

ordered list of content types for the response

getWindowStateback to summary
public WindowState getWindowState()

Redeclares javax.portlet.RenderState.getWindowState.

Returns the current window state of the portlet.

If called during a request where the cache level is set to ResourceURL.FULL, the window state will not be available.

Returns:WindowState

the window state. The window state UNDEFINED will be returned if the cache level is set to ResourceURL.FULL.

Since
3.0
isAsyncStartedback to summary
public boolean isAsyncStarted()

Checks if this request has been put into asynchronous mode.

A ResourceRequest is put into asynchronous mode by calling startAsync() or startAsync(ResourceRequest,ResourceResponse) on it.

This method returns false if this request was put into asynchronous mode, but has since been dispatched using one of the AsyncContext#dispatch methods or released from asynchronous mode via a call to AsyncContext#complete.

Returns:boolean

true if asynchronous mode has been started

Since
3.0
See Also
startPortletAsync(), startPortletAsync(ResourceRequest, ResourceResponse)
isAsyncSupportedback to summary
public boolean isAsyncSupported()

Checks if this request supports asynchronous operation.

Asynchronous operation is disabled for this request if this request is within the scope of a filter or servlet that has not been annotated or flagged in the portlet configuration as being able to support asynchronous handling.

Returns:boolean

true if this request supports asynchronous operation

Since
3.0
startPortletAsyncback to summary
public PortletAsyncContext startPortletAsync() throws IllegalStateException

Puts this request into asynchronous mode and initializes the AsyncContext object.

Calling this method will cause committal of the associated response to be delayed until AsyncContext#complete is called on the returned AsyncContext, or the asynchronous operation has timed out.

This method clears the list of AsyncListener instances (if any) that were registered with the AsyncContext returned by the previous call to one of the startAsync methods, after calling each AsyncListener at its onStartAsync method.

Subsequent invocations of this method, or its overloaded variant, will return the same AsyncContext instance, reinitialized as appropriate.

The AsyncContext object can be used as described by the servlet specification. The ServletRequest and ServletResponse objects obtained from the AsyncContext will provide functionality appropriate for the portlet environment.

The original ResourceRequest and ResourceResponse objects will be made available as request attributes on the code>ServletRequest object obtained from the AsyncContext under the names javax.portlet.request and javax.portlet.response, respectively. The PortletConfig object will be made available on the ServletRequest under the name javax.portlet.config.

The AsyncContext#dispatch() method will cause the portlet resource method to be invoked with the ResourceRequest and ResourceResponse objects available as attributes on the ServletRequest object obtained from the AsyncContext. In this case, the ResourceRequest#isAsyncStarted() method will return false and the ResourceRequest#getDispatcherType() method will return DispatcherType#ASYNC.

A portlet ResourceFilter that allocates resources and attaches them to the ResourceRequest or that wraps the ResourceRequest or ResourceResponse should not release resources in the outbound direction if asynchronous mode has been started. A portlet ResourceFilter can use the values provided by the ResourceRequest#isAsyncStarted() and the ResourceRequest#getDispatcherType() methods to determine when to allocate and release resources.

Returns:PortletAsyncContext

the (re)initialized AsyncContext

Exceptions
IllegalStateException:
if this request is within the scope of a filter or servlet that does not support asynchronous operations (that is, isAsyncSupported() returns false), or if this method is called again without any asynchronous dispatch (resulting from one of the PortletAsyncContext#dispatch methods), is called outside the scope of any such dispatch, or is called again within the scope of the same dispatch, or if the response has already been closed
Since
3.0
See Also
javax.servlet.ServletRequest#startAsync(), javax.servlet.AsyncContext, isAsyncStarted(), getDispatcherType(), javax.portlet.filter.ResourceFilter
startPortletAsyncback to summary
public PortletAsyncContext startPortletAsync(ResourceRequest request, ResourceResponse response) throws IllegalStateException

Puts this request into asynchronous mode and initializes the AsyncContext object.

Calling this method will cause committal of the associated response to be delayed until AsyncContext#complete is called on the returned AsyncContext, or the asynchronous operation has timed out.

This method clears the list of AsyncListener instances (if any) that were registered with the AsyncContext returned by the previous call to one of the startAsync methods, after calling each AsyncListener at its onStartAsync method.

The AsyncContext object can be used as described by the servlet specification. The ServletRequest and ServletResponse objects obtained from the AsyncContext will provide functionality appropriate for the portlet environment.

The ResourceRequest and ResourceResponse objects passed as arguments to this method will be made available as request attributes on the code>ServletRequest object obtained from the AsyncContext under the names javax.portlet.request and javax.portlet.response, respectively. The PortletConfig object will be made available on the ServletRequest under the name javax.portlet.config.

Subsequent invocations of this method, or its zero-argument variant, will return the same AsyncContext instance, reinitialized as appropriate. If a call to this method is followed by a call to its zero-argument variant, the specified (and possibly wrapped) ResourceRequest and ResourceResponse objects will remain available as request attributes on the ServletRequest object obtained from the AsyncContext.

The AsyncContext#dispatch() method will cause the portlet resource method to be invoked with the ResourceRequest and ResourceResponse objects available as attributes on the ServletRequest object obtained from the AsyncContext. In this case, the ResourceRequest#isAsyncStarted() method will return false and the ResourceRequest#getDispatcherType() method will return DispatcherType#ASYNC.

A portlet ResourceFilter that allocates resources and attaches them to the ResourceRequest or that wraps the ResourceRequest or ResourceResponse should not release resources in the outbound direction if asynchronous mode has been started. A portlet ResourceFilter can use the values provided by the ResourceRequest#isAsyncStarted() and the ResourceRequest#getDispatcherType() methods to determine when to allocate and release resources.

Returns:PortletAsyncContext

the (re)initialized AsyncContext

Exceptions
IllegalStateException:
if this request is within the scope of a filter or servlet that does not support asynchronous operations (that is, isAsyncSupported() returns false), or if this method is called again without any asynchronous dispatch (resulting from one of the PortletAsyncContext#dispatch methods), is called outside the scope of any such dispatch, or is called again within the scope of the same dispatch, or if the response has already been closed
Since
3.0
See Also
javax.servlet.ServletRequest#startAsync(), javax.servlet.AsyncContext, isAsyncStarted(), getDispatcherType(), javax.portlet.filter.ResourceFilter