The JSP include directive allows you to include the content of a web page in the current web page.
The location where you insert the include directive in a web page is very important because it is at that specific location where the content of
a web page is added in the current web page.
Syntax of include Directive
<%@ include file = " relative URL of the file " %>
include Directive Example
We have created a JSP web page that displays the current day, date and time, as shown below.
<%@page import="java.util.*" %>
Current Date and Time : <%= new Date() %>
Next we have created a web page that uses include directive to include the contents of a web page Date.jsp(which displays the current date and time)
at a particular location of the current web page.
Including the content of another page using include directive :
<%@ include file="Date.jsp" %>
executing this JSP page includes the content of Date.jsp and displays it the user.
Another example of include directive
In this example, we are going to include a webpage with a form, using include directive.