Passing arbitrary data between JSP pages and SiteMesh decorators
I try not to complain about lack of documentation. So in this blog entry, I'll show how simple it is to pass in arbitrary data from JSP pages to SiteMesh decorators.
For every piece of information that you want to pass from the JSP page to the SiteMesh decorator, create a
<content> tag. In the following example, I want to pass in two pieces of data, a "page name" and a "site section". So I must declare two content tags in the JSP page:
Now, all thats left is telling the SiteMesh decorator to access this information, and that is very easily done using the following syntax in the decorator:
That's it. Now you can pass in anything you want and aren't restricted to using
<decorator:title/>. My problem with these three tags is that I don't want to declare a head, title and body tag for every JSP page since the JSP page is usually the "main" content of the page and shouldn't have to declare such basic HTML elements. IMHO using
<content> tag is also a fine strategy.