The actionScopedRequestAttributes container runtime option

One common issue in working with standard compliant portlet is how do i pass data from action phase(processAction()) to render phase (render()). In order to take advantage of portlet life cycle normally we should execute the business logic to get data from back end in the processAction() method and then pass the complex object from processAction() to render() method but the problem is the we cannot pass complex object we can only pass string parameters by calling PortletResponse.setRenderParameter() method, only alternative is to use the PortletSession

The Portlet Specification introduced concept of container run time options that allows us to modify/ tune behavior of the portlet container. It introduced a javax.portlet.actionScopedRequestAttributes which is set to false by default, but if you set its value to true then you can set request attribute in the processAction() method and you should be able to access those request attributes in the render() method. These request attributes will be preserved until the next action or event request. One drawback of this approach is the request attributes are stored in PortletSession under the hood and it has performance implications of storing data in portlet session, but positive side this approach is better than storing and removing objects in session by yourself.

I wanted to try this feature so I did create ActionScopeRequestAttributePortelt portlet.

This is how my portlet.xml file looks like

<?xml version="1.0" encoding="UTF-8"?>
<portlet-app xmlns="" version="2.0"
<display-name xml:lang="en">ActionScopeRequestAttribute</display-name>

As you can see the value of actionScopedRequestAttributes is set to true. THis is how the portlet code looks like

package com.webspherenotes.jsr286;


import javax.portlet.ActionRequest;
import javax.portlet.ActionResponse;
import javax.portlet.PortletException;
import javax.portlet.PortletRequestDispatcher;
import javax.portlet.RenderRequest;
import javax.portlet.RenderResponse;

public class ActionScopeRequestAttributePortlet extends javax.portlet.GenericPortlet {
public void doView(RenderRequest request, RenderResponse response)
throws PortletException, IOException {
// Set the MIME type for the render response
System.out.println("doView(), Exiting Value of request attribute"
+ request.getAttribute("userName"));

PortletRequestDispatcher rd = getPortletContext().getRequestDispatcher("/action.jsp");

public void processAction(ActionRequest request, ActionResponse response)
throws PortletException, {
System.out.println("processAction(), Exiting Value of request attribute"
+ request.getAttribute("userName"));
System.out.println("Setting request attribute userName to "
+ request.getParameter("userName"));
request.setAttribute("userName", request.getParameter("userName"));


In the processAction() method i am storing the value of userName submitted by the user as request attribute and then in the .jsp i am just reading the values from renderRequest and display it to user like this

<%@page language="java" contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1" session="false"%>
<%@taglib prefix="portlet" uri=""%>
<portlet:defineObjects />
<portlet:actionURL var="actionUrl">
<portlet:param name="action" value="submit" />
<form method="post" action="<%=actionUrl %>">
<td>Value stored in request attribute</td>
<td colspan="2">
<%=renderRequest.getAttribute("userName") %>
<td>User Name</td>
<td><input type="text" name="userName" /></td>
<td><input type="submit" name="submit" value="Submit" /></td>


I tried this code in WPS 7.0 and it worked, so i used the How to inspect the values stored in the Portlet Session to check the PortletSession and i can see the attribute in the PORTLET_SCOPE


ggoh said...

One aspect to take in consideration, is that changing the container runtime option to true is not advised by IBM.

It the following article it identifies to "use this feature only if you cannot avoid it, as it will probably cause some performance degradation".

However, I'm not sure if this is still applicable in WPS7, as it does identify this logic is dependent on the portal container and is an old article.

If you find any additional feedback on this, will be much appreciated.


Anonymous said...

This feature doesn't seem to working in Websphere portal 7. I tried using container runtime option in both the portlet level and application level. Still there is no effect. Is there anyother configuration that I am missing?

gobozov said...

Not works for me. WPS 7

Mikhael Pastushkov said...

It doesn't work for me too. WPS7

srjwebsolutions said...

We are leading responsive website designing and development company in Noida.
We are offering mobile friendly responsive website designing, website development, e-commerce website, seo service and sem services in Noida.

Responsive Website Designing Company in Noida
Website Designing Company in Noida
SEO Services in Noida
SMO Services in Noida

Vikas Chaudhary said...

Battery Mantra is Authorized exide car battery dealer in Noida and Greater Noida. We are providing our service in Indirapuram, Delhi, Ashok Nagar.

Exide Battery Dealer in Noida
Battery Dealer in Noida
Authorized Battery Dealer in Noida
Car Battery Dealer in Noida
Car Battery Dealer
Exide Battery Dealer

EG MEDI said... is online medical store pharmacy in laxmi nagar Delhi. You can Order prescription/OTC medicines online.
Cash on Delivery available. Free Home Delivery

Online Pharmacy in Delhi
Buy Online medicine in Delhi
Online Pharmacy in laxmi nagar
Buy Online medicine in laxmi nagar
Onine Medical Store in Delhi
Online Medical store in laxmi nagar
Online medicine store in delhi
online medicine store in laxmi nagar
Purchase Medicine Online
Online Pharmacy India
Online Medical Store