How to Access HttpRequest from Flex Data Services 2
Sometimes in a flex app that is deployed as part of a java web app you will need to know who is the currently logged in user. To do this in Flex 1.5 you could use the flashGateway.Gateway class. In Flex 2.0 this is done using the flex.messaging.FlexContext class (part of the flex-messaging.jar file). Use the appropriate class in java code to get access to the HttpServletRequest object and thus get to the current user. This java code would then be exposed to flex as either a web service or a remote object.Â
Example Java Remote Method for Flex 2.0:
 public String getCurrentUserName() {
  return flex.messaging.FlexContext.getHttpRequest().getUserPrincipal().getName();
 }
08.17.06
by Steve Gudmundson