Reference: Https://stackoverflow.com/questions/10529963/what-is-the-best-way-to-create-jsp-layout-template
In the development of the front-end Web page, the site generally has a template page, to save the entire site The most basic style, and other pages are in this style to modify. This function can be implemented by tag in JSP.
Create a new Base.tag template page in the web-inf/tags/directory to save the newly created template:
<% @tag description= "Overall page template" pageencoding= "UTF-8"%> <%@ taglib prefix= "C" uri= " Http://java.sun.com/jsp/jstl/core "%> <% @attribute name=" num "rtexprvalue=" false "required=" true "%> <% @attribute name= "header" fragment= "true" required= "true"%> <% @attribute name= "Footer" fragment= "True" required= "true"%>
In this template we define two replaceable parts: header,footer, a variable num.
The Sub-page uses this label as follows:
<% @taglib prefix= "T" tagdir= "/web-inf/tags"%> <t:base num= "abc" > <jsp:attribute name= " Header "> <title>Welcome</title>
Content layout in a JSP