4 Replies Latest reply on Jul 13, 2007 6:12 AM by Pedro Varela

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

    Alejandro_Stornelli
      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 ?