An HttpRequest object is only valid within the context of a Servlet servicing a specific request. You probably don't want to hang onto this instance, and it will only be non-null in FlexContext while a request is being processed. That's try of all the getters on FlexContext; their state is valid while a request is being processed, and will generally be null at all other times and in any other context.
If the client is interacting with the server over an Http-based channel, the server-side FlexSession will actually be wrapping the J2EE server's HttpSession instance. So if you code against FlexSession, any attributes you set are written through to the Java HttpSession, and you can read any attributes that were previously set in the HttpSession. Best, Seth ________________________________ From: [email protected] [mailto:[EMAIL PROTECTED] On Behalf Of vttanhua Sent: Friday, January 11, 2008 11:40 PM To: [email protected] Subject: [flexcoders] Managing (http)session data from java code I'm trying to access http session from java code (separate EJB3 project)(through FlexContext.getHttpRequest()) but when I'm trying to use my class from other java classes I get nullpointer exception for FlexContext.getHttpRequest(). So am I missing some important point here? I have created a java class like this: public class SessionRO { public HttpServletRequest request = null; public FlexSession session = null; public SessionRO() { request = FlexContext.getHttpRequest(); session = FlexContext.getFlexSession(); } public String getAttribute(String keyName){ return (String)FlexContext.getHttpRequest ().getAttribute(keyName); } public void setAttribute(String keyName, String value) { FlexContext.getHttpRequest().setAttribute (keyName, value); }

