Bring in the decorators – SiteMesh!
There are several approaches to keep a consistent look and feel for your web application. Lots of times the site will contain a navigation bar, a heading maybe a footer. Of course you can do this using frames or jsp includes. Well frames are probably a thing of the past. And using includes is not very flexible and easy to maintain.
Of course you are thinking tiles now. And indeed if we had used tiles it would have been a lot easier.
But this weekend I stumbled upon SiteMesh
SiteMesh is a web-page layout and decoration framework and web- application integration framework to aid in creating large sites consisting of many pages for which a consistent look/feel, navigation and layout scheme is required.
SiteMesh intercepts requests to any static or dynamically generated HTML page requested through the web-server, parses the page, obtains properties and data from the content and generates an appropriate final page with modifications to the original. This is based upon the well-known GangOfFour Decorator design pattern.
Well I tried it and I like it very much. It is very easy to set up (less than 5 minutes) and works like a charm. It is non-invasive very flexible and extendable. I think it is easier to use than tiles.
One of the standard mappers allows you to specify a separate decorator for different browser. Again using it is a snap.
Next web-app I’m involved with will use SiteMesh for sure