Expand my Community achievements bar.

Retrieving session data in remote objects with FlexContext.getFlexSession().getAttribute(myName) doesn´t work

Avatar

Level 1
Here is a jsp page (fww_prueba_ale.jsp) that references a swf
(compiled from sessionDataManagerCaller.mxml) that only makes a
call to a Remote Object (SessionDataManager.java) that try to
obtain information from the session. In the jsp, i set a session
attribute myName, with the value Paolo and i print it and the
session ID. In the remote object, i try to get the value of that
attribute, but it is null. The session ID is not the same either.



public class SessionDataManager

{

public SessionDataManager()

{

System.out.println("Constructor de SessionDataManager");

}



public Object[] manipulateSessionData()

{



System.out.println("EN getManipulateSessionData()");



HttpServletRequest req = FlexContext.getHttpRequest();

FlexSession flxSession = FlexContext.getFlexSession();



System.out.println("FlexContext.getHttpRequest().getSession().getId():
"+

FlexContext.getHttpRequest().getSession().getId());



System.out.println("FlexContext.getFlexSession().getId(): "+

FlexContext.getFlexSession().getId());



System.out.println("FlexContext.getFlexSession().getAttribute(myName):
"+

FlexContext.getFlexSession().getAttribute("myName"));



System.out.println("FlexContext.getHttpRequest().getSession().getAttribute(myName):
"+


FlexContext.getHttpRequest().getSession().getAttribute("myName"));





ArrayList list=new ArrayList();

return list.toArray();



}



fww_prueba_ale.jsp



<%

request.getSession().setAttribute("myName", "Paolo");

System.out.println("request.getSession().getId():
"+request.getSession().getId());


System.out.println("request.getSession().getAttribute(myName):
"+request.getSession().getAttribute("myName"));



%>





<embed pluginspage='
http://www.macromedia.com/go/getflashplayer'

width='750'

height='200'

src='
http://pc8251e:7001/samples/pruebasAle/sessionDataManagerCaller.swf'

SWLIVECONNECT='true'

/>



sessionDataManagerCaller.mxml



<?xml version="1.0" encoding="utf-8"?>

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


layout="absolute"


creationComplete="{sessionDataManager.manipulateSessionData()}">



<mx:RemoteObject id="sessionDataManager"
destination="mySessionDataManager"

showBusyCursor="true" />



</mx:Application>







Here is the output



request.getSession().getId():
E2I5XlTyMYndIMX281Q1B6dMnrm2IOAOKhzH11iB44ERpxviAd0j!268988011!1153321145080

request.getSession().getAttribute(myName): Paolo

[Flex] [DEBUG] Executed command: (default service)

commandMessage: Flex Message
(flex.messaging.messages.CommandMessage)

operation = client_ping

messageRefType = null

clientId = 9650CC42-320B-D15B-83D2-0701A9C6D2BD

correlationId =

destination =

messageId = 5DF87294-0D64-8BC9-8809-874C180389C7

timestamp = 1153321146962

timeToLive = 0

body = {}

replyMessage: Flex Message
(flex.messaging.messages.AcknowledgeMessage)

clientId = 9650CC42-320B-D15B-83D2-0701A9C6D2BD

correlationId = 5DF87294-0D64-8BC9-8809-874C180389C7

destination = null

messageId = 9650CC42-321A-F616-A28D-D9BC3D589407

timestamp = 1153321146972

timeToLive = 0

body = null



[Flex] [DEBUG] Before invoke service: remoting-service

incomingMessage: Flex Message
(flex.messaging.messages.RemotingMessage)

operation = manipulateSessionData

clientId = 9650CDB0-680B-2744-5618-F3B3B96F8FA4

destination = mySessionDataManager

messageId = 47DD33E4-19DF-37A1-9620-874C17DB93FE

timestamp = 1153321147112

timeToLive = 1153321147112

body = null

hdr(DSEndpoint) = my-amf



EN getManipulateSessionData()

FlexContext.getHttpRequest().getSession().getId():
E2I5XlTyMYndIMX281Q1B6dMnrm2IOAOKhzH11iB44ERpxviAd0j!268988011!1153321146612

FlexContext.getFlexSession().getId():
E2I5XlTyMYndIMX281Q1B6dMnrm2IOAOKhzH11iB44ERpxviAd0j!268988011!1153321146612

FlexContext.getFlexSession().getAttribute(myName): null

FlexContext.getHttpRequest().getSession().getAttribute(myName):
null

[Flex] [DEBUG] After invoke service: remoting-service

reply: java.lang.Object[] (Array length:0)



How can i do this work ?

4 Replies

Avatar

Level 3
Where is the SWF hosted in relation to the JSP page?

Avatar

Level 1
Hi, look i'm frustated because of this, don't know how to do
it.



I have a login page in JSP, when the user login the system do
authentication and save a variable session...

depending the type of user loads X page.. after this.. when X
page appears will be my Flex App.. in ther I need to read the
session variable.. and that's what i don't know how to do.. If you
have any information i will be thankful.

Thanx

Avatar

Former Community Member
You'd have to make sure that the Flash Player sent the same
session cookie

on any subsequent requests... I'm not sure if the player
shares the same

cookies with the browser? Is your JSP on the same server as
the remote object?





Avatar

Level 1
thanx.. for the response. i already solve my problem