Thanks Lukasz, this solved the problem. I really appreciate your help. Perhaps it should be mentioned more clearly in the documentation that interceptors are meant to be singletons. (If its already mentioned and I missed it, I apologize).
One more question which I'd appreciate if you could answer. Is anything stored via: ServletActionContext.getContext().put(..) unique per request as well? E.g, if multiple concurrent requests were being made to /foo action, and in the interceptor I was putting a db connection object in ServletActionContext.getContext() for each request, can I be sure that each db connection put there will only be shared by the instance of the Action for that particular request? Thanks. On Mon, Nov 4, 2013 at 3:10 PM, Lukasz Lenart <lukaszlen...@apache.org>wrote: > 2013/11/4 Ali Akhtar <ali.rac...@gmail.com>: > > no, pure struts. The class that it extends from is included in the same > > package. Not sure why it'd look like a singleton > > First of all your interceptor is broken - each interceptor is a > singleton so you cannot change its state as thus will affect request > processing - which means you cannot assign action, request, whatever > to fields in interceptor and expect it will behave the same way as > usual ;-) > > My example is using local reference to action and now everything is ok. > > public String intercept(ActionInvocation ai) throws Exception { > AjaxAction action = (AjaxAction) ai.getAction(); > try { > Thread.sleep(1000); > } catch (Exception e) { > e.printStackTrace(); > } > > String result = ai.invokeActionOnly(); > AjaxAction action2 = (AjaxAction) ai.getAction(); > if (!action.toString().equals(action2.toString())) { > String error = "Original: " + action.toString() + ", now: > " + action2.toString(); > System.out.println(error); > } > System.out.println("result " + result); > return null; > } > > > Regards > -- > Ćukasz > + 48 606 323 122 http://www.lenart.org.pl/ > > --------------------------------------------------------------------- > To unsubscribe, e-mail: user-unsubscr...@struts.apache.org > For additional commands, e-mail: user-h...@struts.apache.org > >