File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Portals and Portlets and the fly likes How to display the results of one portlet in another portlet(JSR 168 )? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Portals and Portlets
Bookmark "How to display the results of one portlet in another portlet(JSR 168 )?" Watch "How to display the results of one portlet in another portlet(JSR 168 )?" New topic

How to display the results of one portlet in another portlet(JSR 168 )?

P M Rao

Joined: Apr 29, 2008
Posts: 2
Hi all,

I have a portal page with 3 portlets developed following the JSR 168 specification standards. Now, I want to display the results of 1st portlet in 2nd portlet when a submit button is clicked on the first portlet. Is there any solution to achieve this ? All the portlets are developed using Spring porltet mvc framework, portal server is Vignette 7.2 and application server is weblogic 8.1.5. Thanks in advance.
Ben Souther

Joined: Dec 11, 2004
Posts: 13410

"P M R",
Please check your private messages.

Java API J2EE API Servlet Spec JSP Spec How to ask a question... Simple Servlet Examples jsonf
Srikanth Ganji

Joined: Apr 03, 2008
Posts: 24
Hi Ben

Can you Pl. send me also as I have the same requirement.

Thanks & regards
Cameron Wallace McKenzie
author and cow tipper
Saloon Keeper

Joined: Aug 26, 2006
Posts: 4968

This all depends on where the other portlet resides.

Two portlets in a common war file can share information through the PortletSession's APPLICATION_SCOPE. Portlets packaged in different war files cannot.

CBT Tutorial on How to Use the PortletSession's APPLICATION Scope

A single portlet can have several JSP pages associated with it. So, a portlet can get fed input from one JSP, and display results generated by a different JSP. This might accomplish your request a bit better. For more advanced, wizard like applications, you can always use the JSF Portlet or the Struts Portlet. I have some tutorials on how to create those in my signature links.

For portlets in separate war files, you can always write data to a database table in one, and have the other portlet read from that database table and generate the results. JDBC is available in all portlets. IBM has something called a PortletService that helps facilitate this process.

All of this though is a way of saying that really, it's not inherently possible to have one portlet display the results of the other portlet. Portlets are intended to be independed of each other. What if the user removed that second portlet from their page? You'd have one portlet taking in data, but no portlet to display the data. Does that make sense? Probably not.

Being a portlet developer requires a bit of a mind shift away from Servlets and JSPs. Start trying to think like a portlet developer, and you'll run into less of these issues.

Best of luck!

-Cameron McKenzie
P M Rao

Joined: Apr 29, 2008
Posts: 2
Hi Cameron,

Thanks a lot for your reply.
To be more specific,
All the 3 portlets are in the same war file.1st portlet is associated with 2 different jsp' jsp is having input fields and a submit button and the other jsp is for displaying the results. Now if i enter some values in the first jsp and click on submit button the 2nd jsp(results jsp) is displayed replacing the 1st jsp in the same place. But my requirement is, the results jsp has to be displayed in the 2nd portlet with 1st jsp in first portlet remains same even after submit button is clicked.
To achieve this i hav set the values entered by the user in the 1st jsp of first portlet in the application scope. The setting of values into the application scope was done in controller of first portlet. Now i am able to access those values in the controller of 2nd porlet. With these values i called the web service deployed in a remote machine and was able to get the results in the 2nd portlet controller. Now my question is can i display those results in the jsp which is associated to this 2nd controller ?? can anyone please suggest how to do this ?? Please pass your advices if i am wrong with my approach. thanks in advance.
Jonas X. Yuan
Ranch Hand

Joined: May 18, 2008
Posts: 108

Liferay Portal provides one portlet:

Nested portlets: holds one or more portlets inside. It provides nested portlets layout, that is, portlets within portlets.

Abstract from Liferay Book

Books: Liferay Portal 6.1 Systems Development
I agree. Here's the link:
subject: How to display the results of one portlet in another portlet(JSR 168 )?
It's not a secret anymore!