1 Reply Latest reply on Mar 30, 2006 8:57 PM by scottdawson

    PortletSession in JSP (view)


      I am using jspx pages as a view, and came across an issue of accessing portlet session from jspx page.

      I dispatch request to my page using PortletRequestDispatcher :

      javax.portlet.PortletRequestDispatcher prd = this.getPortletContext().getRequestDispatcher("/index.jspx");
      prd.include(request, response);

      the issue arise when I am trying to access session attributes that has been set in processAction method.

      Since session shared between portlets on the page I set session attribute with PORTLET_SCOPE that will add portlet prefix in front of the attribute name. If I am using PortletSession I can retrieve it with no problems, but jsp page got HttpSession that knows nothing about attribute prefix.

      For now I wrote PortletSessionAttributesWrapper that wraps portlet session into Map interface so I can use ExpressionLanguage (EL and JSTL) to access PortletSession attributes.

      request.setAttribute("portletSession", new PortletSessionAttributesWrapper(session));

      But it is way inefficient since session attributes exposed as Enumeration.

      Is there are any other way of solving this issue?

      So far I don't see any other solution.