sonal
sonal

Reputation: 319

How to kill/destroy PortletSession in Liferay?

I am using Portlet to Portlet Communication.In which I created Portlet Session in one Portlet and set attribute.Getting that attribute in second portlet.Now I want to end that session.How can I do this?

Upvotes: 1

Views: 1728

Answers (1)

Runcorn
Runcorn

Reputation: 5226

If you are catching session value in another portlet controller simply use

actionrequest.getPortletSession().removeAttribute("attributeName");

and if you are using Session scope it is better to use

actionRequest.getPortletSession().removeAttribute("attributeName",scopeId);

scopeId can be either one of them

PortletSession.APPLICATION_SCOPE or PortletSession.PORTLET_SCOPE

And now for handling session in jsp (which i rather don't),

PortletRequest portletRequest = (PortletRequest) request.getAttribute(JavaConstants.JAVAX_PORTLET_REQUEST);
portletRequest.getPortletSession().removeAttribute("attributeName");

Upvotes: 3

Related Questions