Spring webflow - how to pass the session in evaluate expression?

Jack Nickels picture Jack Nickels · Jan 18, 2012 · Viewed 12.3k times · Source

I'm using spring webflow, but I need to access my HttpSession in a method that's accessed using a transition ==> evaluate expression. (so in the xml file containing my flow) So far I've yet to find a way to actually pass it to my method. I've taken a look at the flowrequestcontext but so far I haven't found a way yet.

Answer

vliolios picture vliolios · Feb 28, 2012

I think you don't need to pass it as soon as you pass the RequestContext. You can try this:

public class MyAction extends MultiAction{      
    public Event myMethod(RequestContext context){
        HttpSession session = ((HttpServletRequest)context.getExternalContext().getNativeRequest()).getSession();
        ...
    }
}