Forums

Home » Liferay Portal » English » 3. Development

Combination View Flat View Tree View
Threads [ Previous | Next ]
toggle
Andy Murray
session object not carrying forward to flex
September 6, 2012 8:51 AM
Answer

Andy Murray

Rank: New Member

Posts: 11

Join Date: August 8, 2012

Recent Posts

Hi,

Im trying to embed a Flex .swf file.
Im able to use my user info object in servlets / filters simply by : request.getSession().getAttribute(MyUser.usersession);
where request is of type HttpServletRequest.

But when I invoke a class which is specific to flex and try to get this "MyUser" object from FlexContext's session it is not working.
(MyUser)FlexContext.getHttpRequest().getSession().getAttribute(MyUser.usersession);

Any help much appreciated
Andy Murray
RE: session object not carrying forward to flex
September 6, 2012 9:02 AM
Answer

Andy Murray

Rank: New Member

Posts: 11

Join Date: August 8, 2012

Recent Posts

flex util class is just a normal java class. I have BlazeDs jars in my web-inf.
David H Nebinger
RE: session object not carrying forward to flex
September 6, 2012 9:36 AM
Answer

David H Nebinger

Rank: Liferay Legend

Posts: 7250

Join Date: September 1, 2006

Recent Posts

The web application's session is different than the portlet's session. Portlet session is typically scoped within the ROOT web application's session, and this is a different context.
Andy Murray
RE: session object not carrying forward to flex
September 6, 2012 8:33 PM
Answer

Andy Murray

Rank: New Member

Posts: 11

Join Date: August 8, 2012

Recent Posts

Hey David, thats correct....but there should be some way to get this web application session to portlet session...can u suggest me pls
David H Nebinger
RE: session object not carrying forward to flex
September 7, 2012 6:14 AM
Answer

David H Nebinger

Rank: Liferay Legend

Posts: 7250

Join Date: September 1, 2006

Recent Posts

There isn't a natural way. The portlet request, response, and session objects are, by jsr definition, not assumed to be connected with an application container. Therefore although most jsr implementations run within an application container, since they stick to the jsr definition there is no natural way to get where you're trying to go.

However, if you have a PortletRequest object (either an ActionRequest or a RenderRequest), you can use PortalUtil.getHttpServletRequest() to get to the original HTTP request that started everything off, but this only gets you access to the ROOT HttpSession, and not the session from your own war.

Possibly you could get around this by using a ThreadLocal?