This week's book giveaway is in the Jobs Discussion forum.
We're giving away four copies of Java Interview Guide and have Anthony DePalma on-line!
See this thread for details.
The moose likes Portals and Portlets and the fly likes Not able to send data from one struts portlet to another struts portlet Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Java Interview Guide this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Java » Portals and Portlets
Bookmark "Not able to send data from one struts portlet to another struts portlet" Watch "Not able to send data from one struts portlet to another struts portlet" New topic

Not able to send data from one struts portlet to another struts portlet

Bharath Gowda

Joined: Apr 15, 2008
Posts: 17

I'm new to portlet development. I'm trying to send data from one struts portlet to another struts portlet but it is giving error.

<!-- Form Beans -->
<form-bean name="SelectForm" type="com.gdnindia.strutsnav.forms.SelectForm">

<!-- Global Exceptions -->

<!-- Global Forwards -->

<!-- Action Mappings -->
<action path="/SendData" type="com.gdnindia.strutsnav.actions.SendDataAction" name="SelectForm" scope="request">
<forward contextRelative="false" name="success" path="/successpage.jsp">
<%@taglib uri="" prefix="html"%>
<%@taglib uri="" prefix="portlet"%>
<%@taglib uri="" prefix="c"%>
<portlet efineObjects/>
Select a Team:</h3>
<html:form action="/SendData">
<html:select property="selectedItem" onchange="this.form.submit();">
<html ption value="TeamA">Team A</html ption>
<html ption value="TeamB">Team B</html ption>
<html ption value="TeamC">Team C</html ption>
<html ption value="TeamD">Team D</html ption>

<td align="left">SelectedItem:</td>
<td><c ut value="${sessionScope.selectedItem}" /></td>

<%@page language="java" contentType="text/html; charset=ISO-8859-1"
<%@taglib uri="" prefix="portlet"%>
<%@taglib uri="" prefix="html"%>
<%@taglib uri="" prefix="bean"%>
<%@taglib uri="" prefix="c"%>

<%@page import="javax.portlet.PortletSession"%>

<portlet efineObjects />
<% PortletSession s = renderRequest.getPortletSession();
String data = (String) s.getAttribute("javax.portlet.request");
if (data == null || data.length() == 0)
data = "no data found"; %>
<h3>Team selected is:</h3>

<td align="left">SelectedItem:</td>
<td><c ut value="${data}" /></td>


public class SendDataAction extends StrutsAction implements IStrutsPrepareRender


public ActionForward execute(ActionMapping mapping, ActionForm form, PortletRequest request, PortletResponse response)
throws Exception {

ActionErrors errors = new ActionErrors();
ActionForward forward = new ActionForward(); // return value

try {
System.out.println(" ---- Entering SendDataAction to retrive the value---");

PortletSession psession = request.getPortletSession();
//RenderRequest pReq = (RenderRequest) request
RenderResponse rRes = (RenderResponse) request
//PortletConfig portletConfig = (PortletConfig) request.getAttribute("javax.portlet.config");

String teamname = request.getParameter("selectedItem");
System.out.println("***Team Name VALUE ***" + teamname);
psession.getAttribute("selectedItem", psession.APPLICATION_SCOPE);
System.out.println("***Team Name VALUE ***" + psession.getAttribute("selectedItem", psession.APPLICATION_SCOPE));
System.out.println("***Leaving SendDataAction to retrive the value***");

} catch (Exception e) {

public class SelectForm extends ActionForm


private static final long serialVersionUID = -6313074275445304102L;
private String SelectedItem = null;

* Get SelectedItem
* @return String
public String getSelectedItem() {
return SelectedItem;

* Set SelectedItem
* @param <code>String</code>
public void setSelectedItem(String s) {
this.SelectedItem = s;


I'm trying to do this from 2 days. but i'm getting "400 Invalid path /SendData was requested" error...I'm going crazy, Please let me know what is wrong with the implementation. I'm using IBM RAD 7.0, Websphere portal 6.0 server

Or if you have any sample code to implement this, please share it with me.

Bharath PU<br />SCJP - 1.4 <br />IBM Certified Database Associate<br />IBM Certified Advanced Application Developer -- Rational Application Developer for WebSphere Software V6.0
Cameron Wallace McKenzie
author and cow tipper
Saloon Keeper

Joined: Aug 26, 2006
Posts: 4968

Typically, porlets can't talk to each other. If they are in a common war, they can share information through the APPLICATION_SCOPE of the Session, but even that can be tricky with a Struts portlet.

If your portlets are packaged in separate war files, standard development won't allow them to communicate. You need to roll your own solution. A shared database table is a common way to allow portlets to share information. For IBM Portlets, you can use the PortletService.

-Cameron McKenzie
Bharath Gowda

Joined: Apr 15, 2008
Posts: 17
Thanks Cameron. We decided to use JSR 168 basic portlets instead of using struts portlets.
I agree. Here's the link:
subject: Not able to send data from one struts portlet to another struts portlet
It's not a secret anymore!