# What is the function of <jsp:include> action in JSP?

JSPJava 8Object Oriented ProgrammingProgramming

This action lets you insert files into the page being generated. The syntax looks like this −

<jsp:include page = "relative URL" flush = "true" />

Unlike the include directive, which inserts the file at the time the JSP page is translated into a servlet, this action inserts the file at the time the page is requested.

Following table lists out the attributes associated with the include action −

S.No.Attribute & Description
1page
The relative URL of the page to be included.
2flush
The boolean attribute determines whether the included resource has its buffer flushed before it is included.

## Example

Let us define the following two files (a)date.jsp and (b) main.jsp as follows −

Following is the content of the date.jsp file −

<p>Today's date: <%= (new java.util.Date()).toLocaleString()%></p>

Following is the content of the main.jsp file −

<html>
<title>The include Action Example</title>
<body>
<center>
<h2>The include action Example</h2>
<jsp:include page = "date.jsp" flush = "true" />
</center>
</body>
</html>

Let us now keep all these files in the root directory and try to access main.jsp. You will receive the following output −

## The include action Example

Today's date: 12-Sep-2010 14:54:22
Published on 20-Mar-2019 05:58:32