Here is the scenario.
I created one custom login event using hook . I am passing values from hook to portlet
In the above class we set value in HttpSession. On other side if you try to retrieve this value in your portlet class by using HttpServletRequest (PortalUtil.getHttpServletRequest() or PortalUtil.getOriginalHttpServletRequest()) it wont work.
So to retrieve this values from session we can use PortletSession class by setting scope as application
So here is the code from retrieving values from session
PortletSession portletSession = renderRequest.getPortletSession(); portletSession.getAttribute("parameter1" ,PortletSession.APPLICATION_SCOPE)
For communication between two wars (two different portlet) we can use LIFERAY_SHARED_ Prefix
Here is the example to share values across two different wars using session
portletSession.setSetAttribute(LIFERAY_SHARED_PARAM1 , Value,PorletSession.APPLICATION_SCOPE) //And to retrieve value PortletSession.getAttribute(LIFERAY_SHARES_PARAM1,PortletSession.APPLICATION_SCOPE)
Before you set and get this attribute by using PortletSession Please make sure that you have made this entry in liferay-portlet.xml
<private-session-attributes>false</private-session-attributes>
I created one custom login event using hook . I am passing values from hook to portlet
In the above class we set value in HttpSession. On other side if you try to retrieve this value in your portlet class by using HttpServletRequest (PortalUtil.getHttpServletRequest() or PortalUtil.getOriginalHttpServletRequest()) it wont work.
So to retrieve this values from session we can use PortletSession class by setting scope as application
So here is the code from retrieving values from session
PortletSession portletSession = renderRequest.getPortletSession(); portletSession.getAttribute("parameter1" ,PortletSession.APPLICATION_SCOPE)
For communication between two wars (two different portlet) we can use LIFERAY_SHARED_ Prefix
Here is the example to share values across two different wars using session
portletSession.setSetAttribute(LIFERAY_SHARED_PARAM1 , Value,PorletSession.APPLICATION_SCOPE) //And to retrieve value PortletSession.getAttribute(LIFERAY_SHARES_PARAM1,PortletSession.APPLICATION_SCOPE)
Before you set and get this attribute by using PortletSession Please make sure that you have made this entry in liferay-portlet.xml
<private-session-attributes>false</private-session-attributes>