sitemesh 3 can't get session information when decorating the root context path of my webapp

393 views
Skip to first unread message

sirj

unread,
Jul 3, 2012, 1:59:55 AM7/3/12
to sitemes...@googlegroups.com
I have a webapp using sitemesh3, here is the sitemesh3.xml: 
<sitemesh>
  <mapping>
  <path>/mystuff/*</path>
  <decorator>/WEB-INF/decorators/en-layouts/mystuff.jsp</decorator>
  <decorator>/WEB-INF/decorators/en-layouts/header.jsp</decorator>
  </mapping>
  <mapping>
  <path>/*</path>
  <decorator>/WEB-INF/decorators/en-layouts/page.jsp</decorator>
  <decorator>/WEB-INF/decorators/en-layouts/header.jsp</decorator>
  </mapping>

  <mapping path="/js/*" exclude="true"/>
  <mapping path="/css/*" exclude="true"/>
  <mapping path="/images/*" exclude="true"/>
  <mapping path="/bootstrap/*" exclude="true"/>
</sitemesh>

I'm using spring security with this webapp. in the header.jsp, there is some code:
<%
Authentication a = SecurityContextHolder.getContext().getAuthentication();
UserAccount u = null;
if(a != null && a.getPrincipal() != null && a.getPrincipal() instanceof UserAccount){
u = (UserAccount)a.getPrincipal();
request.setAttribute("account", u);
}
%>

and some html:
<p class="navbar-text pull-right">Logged in as <a href="#">${account.nickname }</a></p>

for above JSP code, all pages except http://www.mysite.com/ work very well. when accessing the context root url (/) of the app, variable a is null, i can't get it. when accessing any other pages like http://www.mysite.com/offer/39 or http://www.mysite/mystuff/, all pages are good.

I don't know if my question is clear for you, could you anybody please give me some tips help me out?

thank you in advance.

Regards,
Jason

Joe Walnes

unread,
Jul 5, 2012, 8:08:19 PM7/5/12
to sitemes...@googlegroups.com
Hi Jason

I suspect this is an issue with how the security Filter is configured. If you post your web.xml it may give us more insight.

thanks
-Joe
Reply all
Reply to author
Forward
0 new messages