Difference between @include and jsp:include

UPDATED: 12 November 2014
Today we will understand the difference between <%@include file="header.jsp" %> and <jsp:include page="header.jsp"/>. Its important for Java developer to understand the basic difference and its one of the popular question asked in interviews.

<%@include file="header.jsp" %>

jsp include
Image gives you clear idea about <%@include %>. When you use <%@include %>, It will add page during the translation time of parent page. This will add file content of header.jsp as it is in index.jsp.


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

jsp include
This image also gives you idea about <jsp:include />. When you use <jsp:include />, It will add page when user request for index.jsp. At the runtime header.jsp executed and result of page will be added in index.jsp page.

0 comments :