I'm attempting to integrate SiteMesh into a legacy application using Tomcat 5 as my a container. I have a main.jsp
that I'm decorating with a simple decorator.
In decorators.xml
, I've just got one decorator defined:
<decorators defaultdir="/decorators">
<decorator name="layout-main" page="layout-main.jsp">
<pattern>/jsp/main.jsp</pattern>
</decorator>
</decorators>
This decorator works if I manually go to http://example.com/my-webapp/jsp/main.jsp
. However, there are a few places where a servlet, instead of doing a redirect to a jsp, does a forward:
getServletContext().getRequestDispatcher("/jsp/main.jsp").forward(request, response);
This means that the URL remains at something like http://example.com/my-webapp/servlet/MyServlet
instead of the jsp file and is therefore not being decorated, I presume since it doesn't match the pattern in decorators.xml
.
I can't do a <pattern>/*</pattern>
because there are other jsps that do not need to be decorated by layout-main.jsp
. I can't do a <pattern>/servlet/MyServlet*</pattern>
because MyServlet
may forward to main.jsp
sometimes and perhaps error.jsp
at other times.
Is there a way to work around this without expansive changes to how the servlets work? Since it's a legacy app I don't have as much freedom to change things, so I'm hoping for something configuration-wise that will fix this.
SiteMesh's documentation really isn't that great. I've been working mostly off the example application that comes with the distribution. I really like SiteMesh, and am hoping I can get it to work in this case.