Uploaded image for project: 'PUBLIC - Liferay Portal Community Edition'
  1. PUBLIC - Liferay Portal Community Edition
  2. LPS-30666

Problem in Session Sharing between Portlet and Servlet when name of the variable starts with same shared session attribute keyword.

    Details

      Description

      Tried the session sharing between the life-ray portlet and servlet residing in the same war using the following configuration. And it worked in the liferay version 6.0.6 CE and older version but it is not working in the liferay version 6.1.1 CE GA2

      Enable the Private portlet session by Adding the following tag in the liferay-portlet.xml
      <private-session-attributes>true</private-session-attributes>

      To share the session between portal and portlet. Define the shared session attribute in portal-ext.properties file by configuring the following property in the property file
      session.shared.attributes= LIFERAY_SHARED_ , APP_SHARED_

      In the portlet action set the variable to portlet session. to share that variable with the servlet.

      public class XYZAction extends GenericPortlet {
      ....................

      public void doView(RenderRequest request, RenderResponse response) throws PortletException

      { // Get portlet session PortletSession prtSession = request.getPortletSession(); // Read value of shared variable String testvar = (String) prtSession.getAttribute("APP_SHARED_testvar", PortletSession.APPLICATION_SCOPE); // set variable to portlet session to share with servlet prtSession.setAttribute( "APP_SHARED_testvar", testvar , PortletSession.APPLICATION_SCOPE); }

      .................
      }

      Read the variable in the servlet. And it is not available in servlet.

      public class XYZServlet extends HttpServlet {
      .................
      public void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException

      { ................. HttpSession session = request.getSession(false); // Read variable from the session String testvar = (String) session.getAttribute("APP_SHARED_testvar"); System.out.println("Value of test var : "+testvar); ................. }

      .................
      }

        Attachments

          Activity

            People

            • Votes:
              1 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:
                Days since last comment:
                6 years, 12 weeks, 1 day ago

                Packages

                Version Package
                6.1.1 CE GA2