1. Include directive includes the file at translation time (the phase of JSP life cycle where the JSP gets converted into the equivalent servlet) whereas the include action includes the file at runtime.
  2. If the included file is changed but not the JSP which is including it then the changes will reflect only when we use include action tag. The changes will not reflect if you are using include directive as the JSP is not changed so it will not be translated for request processing and hence the changes will not reflect.
  3. When using include action tag we can also pass the parameters to the included page by using param action tag but in case of include directive it’s not possible.
    <jsp:include page="file_name" />
     <jsp:param name="parameter_name" value="parameter_value" />
    </jsp:include>
    

JSP Include Action tag

<html>
<head>
<title>JSP include Action example</title>
</head>
<body>
<jsp:include page="display.jsp" />
</body>
</html>

JSP Include Directive

<html>
<head>
<title>JSP include Directive example</title>
</head>
<body>
<%@ include file="display.jsp" %>
</body>
</html>
Posted in JSP.

Comments are closed.