How to interpret paths in JSP's inclusion?
For an example of a more complex set of inclusions, consider the following
four situations built using four JSP files: A.jsp, C.jsp,
dir/B.jsp and dir/C.jsp (in the JSP specification 1.2 page 78.):
-
A.jsp says <%@ include file="dir/B.jsp"%> and dir/B.jsp
says <%@ include file="C.jsp"%>. In this case the relative specification "C.jsp"
resolves to "dir/C.jsp"
-
A.jsp says <jsp:include page="dir/B.jsp"/> and dir/B.jsp
says <jsp:include page="C.jsp"/>. In this case the relative specification "C.jsp"
resolves to "dir/C.jsp".
-
A.jsp says <jsp:include page="dir/B.jsp"/> and dir/B.jsp
says <%@ include file="C.jsp" %>.
In this case the relative specification "C.jsp" resolves to "dir/C.jsp".
-
A.jsp says <%@ include file="dir/B.jsp"%> and dir/B.jsp
says <jsp:include page="C.jsp"/>. In this case the relative specification "C.jsp"
resolves to "C.jsp".
Bascilly, the <jsp:include page=... /> happens at runtime but <%@ include file=... %> happens at compile time.
<jsp:include> simply passes control to a different page for a while. Under <jsp:include>, the two pages share 'request' scope but have a different 'page' scope.
You can find more information about the inclusion in JSP pages at When and How to use inclusion in JSP pages?