Seems like something is not correctly initialized in OGNL when you get
the session from the HTTPServletRequest object this way (it should be
documented somewhere or otherwise fix it.)

But you don't need to get both the HTTPSession and the Map to put
something in session scope. The SessionMap is an adapter to ease unit
testing of actions, and every change is is done to the SessionMap it
is delegated to the HTTPSession object.

2008/7/14 Pierre Thibaudeau <[EMAIL PROTECTED]>:
> 2008/7/14 Gabriel Belingueres <[EMAIL PROTECTED]>:
>> Please test your interceptor using the following to get the session:
>> Map session = invocation.getInvocationContext().getSession();
>
> Well, Gabriel:
>
> a)  I'll be d*mned!
> b)  You're a genius!  ;) (I would never have thought of looking that way!)
>
> Now, it's worth making an extra comment about this strange situation.
> I patched my interceptor as follows:
>
>        public String intercept(ActionInvocation invocation) throws Exception {
>                ActionContext context = invocation.getInvocationContext();
>                HttpServletRequest request = (HttpServletRequest)
> context.get(StrutsStatics.HTTP_REQUEST);
>                HttpSession session = request.getSession(true /* create if not 
> yet
> in existence */);
>                Map<?,?> sessionMap = 
> invocation.getInvocationContext().getSession();
>                ...
>        }
>
> In other words, I didn't merely REPLACE my previous HttpSession by the
> Map<?,?>, but I added the Map<?,?>.  With this new setup, so long as I
> put one object in the sessionMap, then the other object (yes, there
> were two of them;  I hadn't mention the second one) is set properly
> with HttpSession.setAttribute(String).  And BOTH object are recognized
> by OGNL, not merely the one that I had Map.put(Object, Object)...
>
> So basically, we are facing an initialization issue somewhere.  I wish
> there was a more elegant way of preparing that new session...  But at
> least, now the interceptor behaves as intended.
>
> I bet this issue should be made explicit in the Strut2 /
> ActionInvocation /OGNL guides...
>
> Thanks!
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to