Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
What is the function of <jsp:include> action in JSP?
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 |
|---|---|
| 1 |
page The relative URL of the page to be included. |
| 2 |
flush 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>
<head>
<title>The include Action Example</title>
</head>
<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
Advertisements