struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Jyothrilinga Rao <jyoth...@gmail.com>
Subject object set in session in interceptor not available to JSP for first launch.
Date Wed, 16 Nov 2011 18:09:24 GMT
Hi,

I have the following configuration snippet in my struts.xml:


<package name=*"default"* namespace=*"/"* extends=*"struts-default"*>
  <interceptors>
   <interceptor name="interceptor1"
    class="com.abc.interceptors.MenuInterceptor">
   </interceptor>
   <interceptor-stack name="myStack">
    <interceptor-ref name="defaultStack">
     <param name="exception.logEnabled">true</param>
     <param name="exception.logLevel">ERROR</param>
    </interceptor-ref>
    <interceptor-ref name="interceptor1" />
   </interceptor-stack>
  </interceptors>
  <default-interceptor-ref name="myStack"></default-interceptor-ref>

i.e I have a interceptor which I am calling after the defaultStack executes.

My MenuInterceptor has the following code fragment in my intercept method
of MenuInterceptor

ActionContext ac = actionInvocation.getInvocationContext();
String result = actionInvocation.invoke();

  if( null==ac.getSession().get("menu")){
    menu = parser.getMenu();
    ac.getSession().put("menu", menu);
  }
LOG.debug("menu from session at end of intercept is:
"+ac.getSession().get("menu"));
return result;

i.e after the action logic executes, I am checking if the sesssion has the
object. if the object is not present I am populating it and storing in the
session.
my LOG outputs valid object in the first launch also.

When I execute for the first time, the menu object is not available in the
JSP, however if I refresh the page, the menu object is available in the JSP.
I could not have my custom interceptor to execute after the default
interceptors stack as the result already gets comitted and I cannot put
object in my session.
I suspect there is something done by some interceptor in the default stack
which I am missing.

Could you please let me know how I can set something in session in
Interceptor and have it available in my JSP.

Thanks,
JK

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message