<p>What would be the Master Pages equivalent in the Java web development world?  I've heard of Tiles, Tapestry and Velocity but don't know anything about them.  Are they as easy to use as Master Pages?  </p>

<p>I want something as easy as set up one template and subsequent pages derive from the template and override content regions, similar to Master Pages.</p>

<p>Any examples would be great!!</p>

[{'answer_id': 25540, 'author': 'Dwight Holman', 'author_id': 2667, 'author_profile': 'https://Stackoverflow.com/users/2667', 'pm_score': 3, 'selected': True, 'text': '<p>First, the equivalent of ASP.Net in Java is going to be a web framework, such as the ones you mention (Tiles, Tapestry and Velocity).</p>\n\n<p>Master pages give the ability to define pages in terms of content slotted into a master template.</p>\n\n<p>Master pages are a feature of ASP.Net (the .Net web framework), so you are looking for a feature similar to master pages in a Java web framework.  </p>\n\n<p><a href="http://tiles.apache.org/framework/tutorial/basic/pages.html" rel="nofollow noreferrer">http://tiles.apache.org/framework/tutorial/basic/pages.html</a> gives some basic examples using Tiles and JSP to implement something similar with Struts, a Java web framework.  In this case, the Master Pages functionality is a plugin on top of Struts.</p>\n\n<p>Velocity is a generic templating engine, not specialized for web pages and definitely more complicated than you need.  (I\'ve seen it used for code generation.)</p>\n\n<p>Tapestry is more of a full featured web stack than Tile, and is probably good for your purposes.  Its templating functionality involves creating a component and putting all common markup in that.  An example is at <a href="http://www.infoq.com/articles/tapestry5-intro" rel="nofollow noreferrer">http://www.infoq.com/articles/tapestry5-intro</a>.</p>\n\n<p>The specifics of this differ based on which Java web framework you choose.</p>\n'}, {'answer_id': 33270, 'author': 'tonygambone', 'author_id': 3344, 'author_profile': 'https://Stackoverflow.com/users/3344', 'pm_score': 4, 'selected': False, 'text': '<p>You should also check out <a href="https://facelets.java.net/" rel="nofollow noreferrer">Facelets</a>; there is a <a href="http://www.ibm.com/developerworks/java/library/j-facelets/" rel="nofollow noreferrer">good introductory article</a> on DeveloperWorks.</p>\n\n<p>The Facelets <code>&lt;ui:insert/&gt;</code> tag is comparable to the ASP.NET <code>&lt;asp:ContentPlaceHolder/&gt;</code> tag used in master pages; it lets you provide default content for that area of the page, but this can be overridden.</p>\n\n<p>To fill the Facelets template in another page, you start with a <code>&lt;ui:composition/&gt;</code> element that points to the template file.  This is roughly equivalent to declaring the MasterPageFile attribute in an ASP.NET page.</p>\n\n<p>Inside the <code>&lt;ui:composition/&gt;</code> element, you use <code>&lt;ui:define/&gt;</code> elements to override the template defaults, similar to the way an <code>&lt;asp:Content/&gt;</code> tag is used.  These elements can contain any kind of content - from simple strings to JSF elements.</p>\n\n<p>So, to bring it all together...</p>\n\n<p>In <em>master.xhtml</em>:</p>\n\n<pre><code>&lt;!-- HTML header content here --&gt;\n&lt;ui:insert name="AreaOne"&gt;Default content for AreaOne&lt;/ui:insert&gt;\n&lt;ui:insert name="AreaTwo"&gt;Default content for AreaTwo&lt;/ui:insert&gt;\n&lt;!-- HTML footer content here --&gt;\n</code></pre>\n\n<p>In <em>page.xhtml</em>:</p>\n\n<pre><code>&lt;ui:composition template="/WEB-INF/templates/master.xhtml"&gt;\n  &lt;ui:define name="AreaOne"&gt;Here is some new content&lt;/ui:define&gt;\n  &lt;ui:define name="AreaTwo"&gt;\n    &lt;p&gt;Some new content here too&lt;/p&gt;\n  &lt;/ui:define&gt;\n&lt;/ui:composition&gt;\n</code></pre>\n\n<p>And this will render as:</p>\n\n<pre><code>&lt;!-- HTML header content here --&gt;\nHere is some new content\n&lt;p&gt;Some new content here too&lt;/p&gt;\n&lt;!-- HTML footer content here --&gt;\n</code></pre>\n\n<p>You also get some other benefits with Facelets, such as the ability to reuse page components with different data.</p>\n\n<p>(Edited to provide more information.)</p>\n'}, {'answer_id': 5192319, 'author': 'Phil Hale', 'author_id': 299048, 'author_profile': 'https://Stackoverflow.com/users/299048', 'pm_score': 2, 'selected': False, 'text': '<p>I\'ve used <a href="http://wiki.sitemesh.org/display/sitemesh/Home" rel="nofollow">sitemesh</a> in previous projects and it\'s pretty easy to set up. Essentially, you create decorators which are equivalents of master pages. You then define which child pages use which decorators. See <a href="http://today.java.net/pub/a/today/2004/03/11/sitemesh.html" rel="nofollow">introduction to sitemesh</a> for more information.</p>\n'}]
['https://Stackoverflow.com/questions/25532', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/2572/']