struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Pierre Thibaudeau" <pierre.thibaud...@gmail.com>
Subject Re: [S2] newly-created Session context
Date Mon, 14 Jul 2008 21:44:05 GMT
2008/7/14 Gabriel Belingueres <belingueres@gmail.com>:
> 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: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Mime
View raw message