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 pass session data between 2  Portlets??? 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 pass session data between 2  Portlets???" Watch "How to pass session data between 2  Portlets???" New topic

How to pass session data between 2 Portlets???

rajen prasad

Joined: Aug 16, 2006
Posts: 15
I have a basic doubt in portals . Can we pass session (HttpSession or PortletSession ) data from one portlet to another portlet???

If yes please tell me how to do that??

Thanks in advance,
Rajendra Prasad.
Cameron Wallace McKenzie
author and cow tipper
Saloon Keeper

Joined: Aug 26, 2006
Posts: 4968

The answer is yes and no.

Not only can portlets not share session data with other portlets, they can't even share session data between the exact same type of portlet if that portlet appears more than once on the same page (portlet instance, I guees).

However, JSR168 introduced something called APPLICATION_SCOPE for portlet session. With application scope, you can share session data between portlets that are part of the same portlet application (packaged in the same war)

This puts something into the session in one portlet, using APPLICATION_SCOPE

This pulls it out:

Note that APPLICATION_SCOPE is not the default.

I have a tutorial that demonstrates how APPLICATION_SCOPE works, and also have a completed JSR168 war file you can download and mess around with the code on your own.

Free Tutorial on the various PortletSession Scopes


-Cameron McKenzie
I agree. Here's the link:
subject: How to pass session data between 2 Portlets???
jQuery in Action, 3rd edition