java+flex开发得到sessionId

可以通过以下方案获取Session中的信息
RemoteObject方式
定义Java代码
import flex.messaging.*;
import java.io.*;
import java.util.*;
import javax.servlet.*;
import javax.servlet.http.*;

public class SessionInfo {
  
  public HttpServletRequest request;
  public FlexSession session;

  public SessionInfo () {
      request = FlexContext.getHttpRequest();            
      session = FlexContext.getFlexSession();    
  }
  
  public String getSessionId() throws Exception {
      String s = new String();
      s = (String) session.getId();            
      return s;
  }

  public String getHeader(String h) throws Exception {
      String s = new String();
      s = (String) request.getHeader(h);            
      return h + "=" + s;
  }
}

Destination]配置
<destination id="myId">
  <properties>
      <source>包名.类名(SessionInfo)</source>
  </properties>
</destination>


AS 角本中获取
ro = new RemoteObject();
ro.destination = "myId";
ro.getSessionId.addEventListener("result", getSessionIdResultHandler);
ro.getSessionId();


WebService方式
生成对应的类
得到sessionId
var sessionId=SessionInfo.getSessionId();//得到sessionId

你可能感兴趣的:(java,xml,servlet,webservice,Flex)