For Tiles, there’s some valuable but less-than-comprehensible code example at http://www.javaworld.com/javaworld/jw-09-2002/jw-0913-designpatterns.html
Background: U have a template file, containing variables, each naming a component-jsp file. Each variable is a place-holder to be substituted by the corresponding jsp.
Q: If you don’t know tiles, how would u do the substitution in a servlet container? How do you assign a header.jsp to the first variable? If first variable names “header.jsp” right within template.jsp , then we can’t reuse template.jsp in another project. We need template.jsp to be free of hard-coding.
A: You need some kind of glue-file. Tiles implents it as a set of definitions spelt out in tiles-defs.xml
Closest starting point: smarty — also contains template, variables holding large content. Smarty uses assign() to put the content into the variables and glue the parts.