0 votes
in JSP by

What is the difference between JSP include directive and JSP include action? (<jsp:include page = … > and <%@ include file = … >). Where we use <jsp:include page = … > and <%@ include file = … > and why?

1 Answer

0 votes
by (2.8k points)

There are following difference between <%@ include file=""> and <jsp:include page="">:

<%@ include file=""> <jsp:include page="">
Static: Include directive used to include the static content or layout templates, like HTML headers, footers and etc. Dynamic: Include action used to include the dynamic content coming from JSPs
It inlcudes at translation time. JSP compiler merge contents It includes at request time.
Only one servlet is executed at run time. Each included page is executed as a separate servlet at run time.
The JSP compilation procedure is that, the source JSP page gets compiled only if that page has changed. If there is a change in the included JSP file, the source JSP file will not be compiled and therefore the modification will not get reflected in the output. If there is a need to pass additional parameters, then jsp:param element can be used. If the resource is static, its content is inserted into the calling JSP file, since there is no processing needed.
<%@include file="header.jsp" %>
Using the include directive.
<jsp:include page="header.jsp" />
Using the include action.


Very good explanation between <%@ include file=""> and <jsp:include page="">

Share:- Whatsapp Facebook Facebook

Welcome to Developerhelpway Q&A, where you can ask questions and receive answers from other members of the community.