Both include directive and include action tag are used to include some jsp page, html page or text file inside another jsp page. Still there are several differences between them that I have explained in this tutorial.
Difference between include directive and include action tag in JSP
|S. No.||include directive||include action tag|
|1.||It includes resource at translation time. Translation is the phase of jsp life cycle in which jsp is converted into servlet.||It includes resource at request time or run time.|
|2.||If the included resource is changed then the changes will not reflect on the jsp page until it is recompiled.||If the included resource is changed then the changes will reflect on the jsp page in next request.|
|3.||Only one servlet will be generated for both source jsp file and included resource.||Separate servlet will be generated for source jsp file and included resource.|
|4.||Its syntax is <%@include file=”resource name”%>||Its syntax is <jsp:include page=”resource name”>|
|5.||We can’t send parameters to included resource.||We can send parameters to included resource by using param action tag. For example:
<jsp:include page=”demo.jsp” />
<jsp:param name=”name” value=”neeraj” />
|6.||Better for including static resource.||Better for including dynamic resource.|
Comment below if you found anything incorrect or missing in above tutorial.