sjivan
Sep 23rd, 2004, 08:15 PM
I have a Sitemesh jps template that has rendering logic based on the authenticated users' role. However the ace context is not available to the template jsp. ie ContextHolder.getContext() returns null.
After doing some further investigation, I think I figured out whats happening. Sitemesh processes the output of the rendered jsp and decorates it based on the template jsp. However this decoration takes place in a separate thread where the Acegi Context is not present in the ThreadLocal variable of the Sitemesh processing thread. I think this issue might also come up in other situations as some web containers process included jsp's in separate threads.
To work around this problem I add the Acegi Context as a session attribute on a successful login. This way I have access to the Context from any thread. Do you see any disadvantages to this approach? The Context will not be available globally to the web app however the user has already been authenticated so it seems okay.
btw great job. Acegi rocks!
Thanks,
Sanjiv
After doing some further investigation, I think I figured out whats happening. Sitemesh processes the output of the rendered jsp and decorates it based on the template jsp. However this decoration takes place in a separate thread where the Acegi Context is not present in the ThreadLocal variable of the Sitemesh processing thread. I think this issue might also come up in other situations as some web containers process included jsp's in separate threads.
To work around this problem I add the Acegi Context as a session attribute on a successful login. This way I have access to the Context from any thread. Do you see any disadvantages to this approach? The Context will not be available globally to the web app however the user has already been authenticated so it seems okay.
btw great job. Acegi rocks!
Thanks,
Sanjiv