Removing session attribute in jsp portlet issue in liferay

After sending data to another portlet through the session, if you want to clear this one sessionAttribute

in the destination portlet, but it doesn't work.

In the destination portlet, I get the session attribute and clear it, but after refreshing the JSP page. The session attribute still exists. It should be null

. How can I get rid of this since the following code doesn't work.

<%@ taglib uri="http://java.sun.com/portlet_2_0" prefix="portlet" %>
<%@page import="javax.portlet.PortletSession" %>
<portlet:defineObjects />

This is the <b>NewPPIPC</b> portlet in View mode.

<%

PortletSession ps = renderRequest.getPortletSession();
String qString = (String)ps.getAttribute("sessionValue",PortletSession.APPLICATION_SCOPE);
ps.removeAttribute("sessionValue");

%>

<h1><%=qString %></h1>

      

+3


source to share


1 answer


The overloaded method uses PORTLET_SCOPE

to find the object, but you need to specify the scope APPLICATION_SCOPE

.



ps.removeAttribute("sessionValue", PortletSession.APPLICATION_SCOPE);

      

+1


source







All Articles