Search code examples
jspcontent-management-systemliferay-6

How can I set PortletSession in JSP page in Liferay MVC?


In a Liferay MVC project how can I set portletSession in JSP page and retrieve portletSession in a custom action class?


Solution

  • From JSP you don't need to do anything because is one of the objects provided:

    <%@ taglib uri="http://java.sun.com/portlet_2_0" prefix="portlet" %>
    <portlet:defineObjects />
    <%
        portletSession.getAttribute(...);
    %>
    

    From a class is not a big deal neither, it's available in your render or action methods:

    PortletSession portletSession = actionRequest.getPortletSession(); // action method
    PortletSession portletSession = renderRequest.getPortletSession(); // render method