Foren

Unable to retive attributes from HttpSession which set in Portlet Session

Subramanyam Busineni, geändert vor 16 Jahren.

Unable to retive attributes from HttpSession which set in Portlet Session

New Member Beitrag: 1 Beitrittsdatum: 08.03.08 Neueste Beiträge


Hi All,

I am new to portlets. I am using liferay 4.3.5.extention environment.

I am setting some attributes in Portlet session in Portlet Action class.

PortletSession ses = request.getPortletSession(); //Here request is RenderRequest object

ses.setAttribute("attribute1","Hello", PortletSession.APPLICATION_SCOPE);

After that I am retriving these attribute using HttpSession in another servlet.

HttpSession session = (HttpSession) req.getSession(); // Here req is object of HttpServletRequest
String attribValue = (String)session.getAttribute("attribute1");

Here I am expecting attribValue value as Hello.
But I am getting null value.

Please let me know how can I get all Portlet session attributes using HttpSession in Servelet.

I deployed three portlets in server. It is happening in the same portlet and accross the portlets.

Thanks in advance for your help.
thumbnail
Tobias Amon, geändert vor 16 Jahren.

RE: Unable to retive attributes from HttpSession which set in Portlet Sessi

Liferay Master Beiträge: 546 Beitrittsdatum: 08.08.07 Neueste Beiträge
Hi,

maybe you want to try one of these solutions:
http://wiki.liferay.com/index.php/Inter-portlet_communication
thumbnail
Richard Cantor, geändert vor 14 Jahren.

RE: Unable to retive attributes from HttpSession which set in Portlet Sessi

New Member Beiträge: 17 Beitrittsdatum: 18.03.09 Neueste Beiträge
Did you ever figure this out?

Please help... got the same problem.

My servlet is in the same webapp.

PortletSession and HttpSession have the same id's.

But portlet session attributes (set in APPLICATION_SCOPE) are not in HttpSession in my servlet.

Please HELP!!!

Thanks,

-Rich
thumbnail
Chris Whittle, geändert vor 14 Jahren.

RE: Unable to retive attributes from HttpSession which set in Portlet Sessi

Expert Beiträge: 462 Beitrittsdatum: 17.09.08 Neueste Beiträge
we changed the liferay-portlet.xml under <portlet></portlet> add <private-session-attributes>false</private-session-attributes> this took care of it for us..
thumbnail
Tomas Polesovsky, geändert vor 14 Jahren.

RE: Unable to retive attributes from HttpSession which set in Portlet Sessi

Liferay Master Beiträge: 676 Beitrittsdatum: 13.02.09 Neueste Beiträge
Hi,

as I understand it, you need the portlet session instance in your servlet. You didn't write how do you access your portlet, so it is harder to solve it, but I can give you hint, hope it helps.

Your portlet application is deployed in the servlet container and portlets are executing within the portlet container. The portlet container use Liferay as surrounding web application. So there are 2 web applications - Liferay and your portlet application.

When you access your portlet, the request goes through servlet container that contains Liferay as web application so your session instance belongs to Liferay web application. Then when it reaches your portlet, you can redirect the internal request into your JSP/servlet using getPortletContext().getRequestDispatcher()... Then your JSP and/or servlet share the same session because they share the same request/response objects.

BUT.

If you access your servlet directly from web browser, you go through servlet container directly to your "portlet" application. And it has it's own HttpSession. It will never reach the portal web application (Liferay) and so it can't reference it's session instance.

Isn't it bad written, do you understand it?