WebSphere Portal Server - Sharing session information among portlets

This is Interesting: Free IT Magazines  
Home > Archive > WebSphere Portal Server > October 2006 > Sharing session information among portlets





You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

Author Sharing session information among portlets
Bala Labhishetty

2006-10-26, 1:34 am

Hi,

How can I share a PortletSession among Portlets. I tried to put the following
entry in the web.xml for each Servlet that needs to share the Portletsession.

<init-param>
<param-name>com.ibm.wps.portlet.session</param-name>
<param-value>shared</param-value>
</init-param>

But It is not working for Websphere Portal 5.1, I followed the following link
http://www-128.ibm.com/developerwor.../0210_lynn.html

Regards,
Bala

2006-10-28, 1:41 pm

Using PortletSession object, data can not be shared between portlets.

"PortletSession can be used to store information needed between requests. The PortletSession is intended to store data between requests, not between portlets. As such, data stored in the session by one portlet is not accessible by another."

Arch
Rama Jaini

2006-10-28, 1:41 pm

The PortletSession interface defines two scopes for storing objects:

APPLICATION_SCOPE
PORTLET_SCOPE

All objects stored in the session using the APPLICATION_SCOPE must be available to all the portlets, servlets and JSPs that belongs to the same portlet application and that handles a request identified as being a part of the same session. Objects stored i
n the session using the PORTLET_SCOPE must be available to the portlet during requests for the same portlet window that the objects where stored from.

for example:
PortletSession session = request.getPortletSession(true);
session.setAttribute(attribute_name, attribute_value, PortletSession.APPLICATION_SCOPE);

More over according to JSR 286 (portlet specification 2.0) Portlets can allow portlet containers to share APPLICATION_SCOPE even beyond the current web application by declaring them as shared session parameters in the portlet deployment descriptor with th
e <shared-session-attribute> element. (refer to JSR 286 for more info)

I hope that helps.

Thanks,

Rama.
Bala Labhishetty

2006-10-28, 1:41 pm

Rama,

setting scope like APPLICATION_SCOPE applicable for jsr168 portlets not for IBM specific portlets.

Anyhow I found one solution (which is not available thru public API), using this api we can set/get attributes to true httpSession.

PortletSessionImpl porsession =(PortletSessionImpl) request.getPortletSession();
HttpSession session = porsession.getHttpSession();

We are doing similar code in jsf pagecode related classes, not directly in portlet code. Above code tested in porlet level code.

Thanks & Regards,
Bala
Sponsored Links






Free braindumps | Software forum | Database administration forum

Copyright 2003 - 2008 webservertalk.com