Skip to content

JSP Templates


Including Files in JSP Pages

Concepts

  • The include directive.

Including Files at Page Translation Time: The include Directive

    <%@ include file="template-example-footer.jsp"%>
  • This will add the contents of the page in the file attribute to the JSP file at Translation time.

Simple Example of Including Files

A Simple Template System for JSP Pages

  1. Take a typical HTML page and slice it up into segments based on tags.

  2. Put each segment into its own file.

  3. Then replace each tag with a JSP include statement.

    Warning

    Don’t split a tag up into multiple files.

Example Code