Share session object between portlets of different CAF packages

Hi Guys,

I have a custom java object. Once user logs into application I need to keep it in browser’s HTTP session. That session scoped object should then be shared/accessible between portlets of two different CAF packages.

Can you please advise which API to be used to implement the above use case?

Environment details -
webMethods 9.8, Two MWS servers clustered in active passive mode.

Hi Raja,

How big is the data you want to carry across session ?
If its not huge, go for cookies.

Below link should guide you with the session implementation you are looking for

http://techcommunity.softwareag.com/web/guest/pwiki/-/wiki/Main/Managing+Session+State+Between+Views+in+a+Web+Application

Thanks
Abdul Bari Khan

@Raja

Are both portlet types involved here within the same CAF application?

If both portlet types are within the same webapp (aka servlet context) then the portlet specification supplies a mechanism to access the per-portlet-application (APPLICATION_SCOPE) session-attribute map by casting the ExternalContext’s session property to a PortletSession (see http://portals.apache.org/pluto/portlet-1.0-apidocs/javax/portlet/PortletSession.html). 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 in 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 portletSession = (PortletSession)getFacesContext().getExternalContext().getSession(true);
Object myAttribute = portletSession.getAttribute("myAttribute", PortletSession.APPLICATION_SCOPE); 

Hi Eric,

The portlets are from two different CAF applications.