JSP Include Directive

As the name implies, include directive is used to include the content of other files such as HTML, JSP, text into the current JSP page. These files are included during translation phase.

Syntax of include directive

<@ include file="file-name">

Include directive tag can be placed anywhere in JSP page.

Example of Include Directive

This example expresses the simple way to include more than one file of different types within JSP page through include directive.

header.html

<h1 align="center">
Tutorial and Example
</h1>

footer.jsp

<h5 align="center">
© Copyright 2011-2018 www.TutorialandExample.com.
</h5>

index.jsp

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Tutorial and Example</title>
</head>
<body>
<%@ include file="header.html"%>
<font size="5">
<p align="center">Learn JSP tutorials</p></font>
<%@ include file="footer.jsp"%>
</body>
</html>
Output: