Up until now, I’ve used Tiles a lot. It always suited my needs pretty well, but on and off I had the feeling something was wrong with it. My biggest complaint: it resembles jsp:includes too much. It doesn’t seamlessly decorate your page. Well, there you have it: the Decorator pattern. Yes, I did look at SiteMesh every now and then, but never found the the time to look at it in more detail than just reviewing their front page. I should have downloaded it, I should have given it a go a long time ago, because it’s matter of ten seconds to get SiteMesh up-and-running.
During one my consulting jobs, I was asked to have a look at a legacy web application (it was developed late 2003, and already legacy), written using Java and JSPs. The JSPs were littered with Java code and every page started with a scriptlet taking care of authentication, the guys built a dispatcher using Java scriptlets in a file called home.jsp. Well, let’s quit bashing the guy who built the app (he left the company already–started emessenger and a couple of days ago during a drink formally offered me his apologies for creating such a mess ;)) and get to the good stuff.
I downloaded SiteMesh and re-wrote the home.jsp file (containing a header, a left-hand menu and a footer). This file turned out to be my first SiteMesh decorator page. I included the SiteMesh filter in my web.xml file:
<filter> </filter><filter -name>sitemesh</filter> <filter -class> com.opensymphony.module.sitemesh.filter.PageFilter </filter>
And mapped all incoming requests to the filter:
<filter -mapping> </filter><filter -name>sitemesh</filter> <url -pattern>/*</url>
and created an decorators.xml file, containing my home.jsp file declared as a decorator:
<decorators> <decorator name="main" page="/WEB-INF/jsp/menu.jsp"> <pattern>/*</pattern> </decorator> </decorators>
The last thing I did was inserting a in my decorator JSP, which I by the way renamed to home.jsp dispatcher JSP, which became my decorator (yes, I removed the dispatcher stuff from it ;)) and I had to call the pages the dispatcher used to dispatch and let SiteMesh decorate them! I searched for an appropriate JSP and called it. You know what: RequestDispatcher as part of a Java Scriptlet in home.jsp. After I showed this to some of the guys in the team, they were literally stunned. They got rid of the dispatcher crap, all of a sudden had the option to include controllers in there webapp and even the impact of changing all this was close to zero!!
Other things I changed to make things meet the requirements:
Including webapp="/" as an attribute of the decorator in decorators.xml. The team wanted to have a pluggable mechanism to be able to deploy parts of the web application independently from the main infrastructural code (the decorators and some supporting functionality). Using the webapp attribute, you’ll be referring to a web application (context) serving as source for your decorator
Tidied up the pages to function independently of eachother (they had some inter-dependencies unfortunately)
Included a Spring FilenameUrlViewController that forwarded all of the JSP requests to the appropriate JSPs after having them moved to /WEB-INF/jsp. They used to be included in the war root, which allowed for calling them directly (not really desirable after I had removed the Scriplets that took care of authentication ;)). So the infrastructure was ready to use Spring MVC stuff as well!
Included a HandlerInterceptor that intercepted all calls to the webapp, adding some custom stuff to the model that was needed by my decorator (I could also have implemented a filter, but that didn’t seem to be the best option)
Conclusion:
I can remember Mike Cannon-Brookes’ presentation at TSSJS last May, titled SiteMesh: the best open source component you’ve never used!. Well, that doesn’t include me (anymore).
If you ever encounter a situation again where you don’t have time to review a certain technology in favor of another, go to bed half an hour later, you won’t be sorry for it!

I’m not surprised that you like SiteMesh. Like you I was intrigued by it for quite a while before using it and found it surprisingly easy to implement. And as far as elegance and not getting in the way of the content is concerned, when compared with the ugliness of Tiles there is no contest!
Amen
This discription is extremly flaw. If yo uuse sitemesh with spring MVC (Controllers, validators etc) it will give you a massive headache because spring will try to forward from the validator to the controller. This will make sitemesh try to wrap the url of the controller in a decorator causing your controller to stop loading because of the url not matching any mapping.