Reputation: 4267
let's say I have a site with 10 pages. Every page is called by a servlet. For example, I have the servlet "index" that makes a forward()
to "index.jsp".
In my index.jsp i have 2 includes for the header and the footer
...
<jsp:include page="header.jsp" >
home page text
<jsp:include page="footer.jsp" >
...
Now I have 10 pages similar to the index page, I mean I have 10 pages that include a header and a footer.
Let's say I decide to delete the footer: I should edit 10 pages.
What im wondering is if there's something that allow me to use just one page, and show, dinamically, just the "content" of the page (home page, contacts, ecc), keeping in mind that i use a servlet to get every page content (with a forward()).
Upvotes: 2
Views: 1070
Reputation: 8207
what you need is Apache Tiles Framework,
Tiles allows authors to define page fragments which can be assembled into a complete pages at runtime. These fragments, or tiles, can be used as simple includes in order to reduce the duplication of common page elements or embedded within other tiles to develop a series of reusable templates. These templates streamline the development of a consistent look and feel across an entire application.
It includes configuration file so you can edit in one file alone , so that the changes will be reflected in common for all jsp files
A nice Startup tutorial here
Upvotes: 2