0

I am trying to share the httpsession between themes and portlet in different portlet application. But it always return null value in the portlet.

The themes is posting in to a servlet to store httpsession :

HttpSession session = request.getSession();
session.setAttribute("testsession", "testsession");

and i tried to retrieve the session in portlet with following ways:

1)

HttpSession session = httpRequest.getSession(false);
System.out.println("session "+session.getAttribute("testsession")); 

2)

System.out.println("portletsession :"+renderRequest.getPortletSession().getAttribute("testsession", PortletSession.APPLICATION_SCOPE));

3)

HttpSession httpSession = PortalUtil.getHttpServletRequest(renderRequest).getSession(false);
         System.out.println("httpSession 212 in java : "+httpSession.getAttribute("testsession"));

All of the above return null. Does anyone have experience in implementing this behaviour before ?

Thanks,

Cyril

a sandwhich
  • 4,352
  • 12
  • 41
  • 62
cyrilforce
  • 11
  • 2

2 Answers2

1

It doesn't work in the private-session-attributes tag. However my solution for this is to embed the portlet into the themes via the portlet instances id.

Here for further information :

http://www.liferay.com/community/wiki/-/wiki/Main/Embedding+a+portlet+in+the+theme

Thanks

cyrilforce
  • 11
  • 2
0

Try setting this attribute in liferay-portlet.xml

<private-session-attributes>false</private-session-attributes>

HTH

Laxman Rana
  • 2,904
  • 3
  • 25
  • 37