I'm about to choose to way to organize my view (with spring-mvc, but that should matter much)
There are 6 options as far as I see (though they are not mutually exclusive):
- tiles
- sitemesh
- freemaker
- velocity
<jsp:include>
<%@ include file="..">
tiles and sitemesh can be grouped; so can freemaker and velocity. Which one within each group to use is not a matter of this discussion, there are enough questions and discussions about it.
This is an interesting read, but can't quite convince me to use tiles.
My question is - what do these frameworks give that can't be properly done with <@ include file="..">
and JSTL. Main points (some taken from the article):
Including parts of pages, like header and footer - there isn't a difference between:
<%@ include file="header.jsp" %>
and
<tiles:insert page="header.jsp" />
Defining parameters in the header - like title, meta tags, etc. This is very important, especially from SEO point of view. With the templating options you can simply define a placeholder which each page should define. But so you can in jsp with JSTL, using
<c:set>
(in the including page) and<c:out>
(in the included page)Layout reorganization - if you want to move the breadcrumb above the menu, or the login box above another side-panel. If page inclusions (with jsp) is not well organized, you might need to change every single page in such cases. But if your layout is not overly complex, and you put the common things in header/footer, there is nothing to worry about.
Coupling between the common components and the specific content - I don't find an issue with this. If you want to reuse some fragment, move it to a page that doesn't include any header/footer, and include it wherever needed.
Efficiency -
<%@ include file="file.jsp" %>
is more efficient than anything else, because it is compiled once. All other options are parsed/executed many times.Complexity - all non-jsp solutions require additional xml files, additional includes, pre-processor configurations, etc. This is both a learning curve and introducing more potential points of failure. Also, it makes support and changing more tedious - you have to check a number of files/configurations in order to understand what's happening.
Placeholders - do velocity/freemaker give anything more than JSTL? In JSTL you put placeholder, and use the model (placed in request or session scope, by controllers) to fill these placeholders.
So, convince me that I should use any of the above frameworks instead of/in addition to plain JSP.