What is the difference between <%@ include file="xyz.jsp" %> and in JSP?

The <%@include file=”xyz.jsp” %> or <%@include file=”xyz.html” %> directive pulls in the text of the included file and compiling it as if it were part of the including file. The included file can be any type (including HTML or text).

The tag compiles the file as a separate JSP file, and embeds a call to it in the compiled JSP. The include action is executed at request time as opposed to translation time. Thus instead of the content of the include file being included in the calling JSP, the output of the JSP is included or passed to the JSPWriter of the calling page. This allows us to include both static and dynamic content into a JSP page. Using the jsp action also allows us to explicitly pass parameters to the included page.

<jsp:include page=”/index_extra.jsp”>
<jsp:param name=”productid” value=”SKU99999″ />
</jsp:include>