Expand my Community achievements bar.

Radically easy to access on brand approved content for distribution and omnichannel performant delivery. AEM Assets Content Hub and Dynamic Media with OpenAPI capabilities is now GA.

Accessing Java Session from Flex

Avatar

Level 1
Hi, I have a JSP login page to access an intranet, inside the
Intranet I have a flex application, to access session info in the
JSP page from my flex application i've created a remote object to
get user info from the session:



<destination id="infoSesion">

<channels>

<channel ref="java-amf" />

</channels>

<adapter ref="java-object" />

<properties>

<source>pe.gob.inccusco.InfoSesion</source>

<scope>session</scope>

</properties>

</destination>



InfoSesion RO code:



package pe.gob.inccusco;



import javax.servlet.http.HttpServletRequest;

import javax.servlet.http.HttpSession;



import flex.messaging.FlexContext;



public class InfoSesion

{

public String getUserInfo()

{

HttpServletRequest req = FlexContext.getHttpRequest();

HttpSession sesion = req.getSession();



....Code to get the user Info using sesion





}

}



I want to access the JSP session info from flex but the
problem is that req.getSession always return a NullPointerException



what am i doing wrong?
2 Replies

Avatar

Level 3
HI,



I don't see any problem from your code. I just verified with
your code and it worked (version LCDS 2.5.1)

package pe.gob.inccusco;



import javax.servlet.http.HttpServletRequest;

import javax.servlet.http.HttpSession;



import flex.messaging.FlexContext;



public class InfoSesion

{

public String getUserInfo()

{

HttpServletRequest req = FlexContext.getHttpRequest();

HttpSession sesion = req.getSession();

return sesion.getId();

}

}



mxml page

<?xml version="1.0"?>

<Application xmlns="
http://www.adobe.com/2006/mxml">

<RemoteObject id="ro" destination="infoSesion">

<method name="getUserInfo" />

</RemoteObject>

<Button click="ro.getUserInfo()"/>

<TextInput text="{ro.getUserInfo.lastResult}"/>

</Application>



William Chan

Avatar

Former Community Member
Are you using ColdFusion but trying to access Java based ROs?
If so, have

you configured ColdFusion to use J2EE sessions?