However, I did not focus on the layout aspect, which glues everything together. Let us
consider a case where you want to display an important notice at the top of every page. If
you are not using subviews with layout, you would have to replicate the notice in each
and every JSP file. However, with layout, you can just change the JSP, which comprises the
header, and revert back when this notice is no longer relevant.
eInsure typically used a table to configure the layout and used JSP includes to
dynamically include subviews to compose the main view. Although this solution works,
it's a very naïve approach requiring lot of custom code to make this a flexible and plug-
gable view framework. Spring provides integration with two view layout frameworks to
ease the development and maintenance of composite views.
SiteMesh is an open source web page layout framework from OpenSymphony. It can be
using SiteMesh is that it is not intrusive. Because it is based on servlet filters, using it is
just a matter of configuration, and it will work even without Spring MVC. Being based on
filters, it implements the GOF Decorator design pattern. It modifies the response from
the front controller servlet to inject content before sending the final response to the
The first step in using SiteMesh is to create a JSP file with the desired layout, as
shown in Listing 3-54.
Listing 3-54. WEB-INF/decorators/primaryLayout.jsp
<%@ taglib uri="sitemesh-decorator" prefix="decorator" %>
<%@ taglib uri="sitemesh-page" prefix="page" %>
eInsure - <decorator:title default="Welcome!" />
<h3>eInsure - rel 3.0.1 </h3>