JSP <jsp:Include> Action



JSP Action Element :

  1. JSP jsp:include Action elements are used to insert files into the page being generated.
  2. JSP jsp:include action inserts the file at the run time when the JSP page is translated into a servlet when requested

Syntax :

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

Above is the basic syntax for the JSP action element. We can use the prefix jsp for indicating the JSP action element.

Attribute Description
page Relative URL of the page to be included into JSP
flush Boolean attribute which determines whether the included resource has its buffer flushed before it is included.

Example :

Consider the following jsp hello.jsp used to show the message -

<html>
<head>
<title>The include Action Example</title>
</head>
<body>
<p>Inside the hello.jsp</p>
<jsp:include page="msg.jsp" flush="true" />
</body>
</html>

Now consider our msg.jsp which will display only message -

<html>
<head>
<title>The include Action Example</title>
</head>
<body>
<p>Inside msg.jsp page</p>
</body>
</html>

Output :

Now when we run the above hello.jsp then we will get the following output -

Inside the hello.jsp
Inside msg.jsp page

include action in jsp