2 Replies Latest reply on Aug 9, 2007 12:42 PM by Newsgroup_User

    Accessing Java Session from Flex

    Jorge Carlos
      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?
        • 1. Accessing Java Session from Flex
          aBill Level 1
          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
          • 2. Re: Accessing Java Session from Flex
            Level 7
            Are you using ColdFusion but trying to access Java based ROs? If so, have
            you configured ColdFusion to use J2EE sessions?