×
☰ See All Chapters

include action tag in JSP

The jsp:include standard action  is used to include static or dynamic resources into the JSP page. It may be jsp, html or servlet. jsp:include provides greater flexibility when compared to include directive. The syntax for the jsp:include action is:

<jsp:include page="resourceRelativeURL" />

Below syntax is valid to pass parameter to the included resource.

<jsp:include page="resourceRelativeURL">

   ( <jsp:param . . . /> )*

</jsp:include>

* indicates that there can be zero or more elements in the brackets.

JSP include Example

Project directory structure

jsp-include-0
 

demo.jsp

<html>

<body bgcolor="pink">

        <center>

                <h1>Hello Welcome</h1>

        </center>

        Below is the contents from included JSP file<br>

        <jsp:include page="include.jsp" /><br>

</body>

</html>

include.jsp

<html>

<body bgcolor="orange">This is content of included JSP file

</body>

</html>

Output

 

jsp-include-1
 

All Chapters
Author