Hai,
Your question was:
Greately appriciate if you can tell me why case 1: is not dir/B.jsp.
I think the question should be why isnt it dir/C.jsp
We have A.jsp, C.jsp, dir/B.jsp and dir/C.jsp,
Lets see what Case 1: does:
(i)
A.jsp says <%@ include file=�dir/B.jsp�%>
There is no ambiguity here - dir/B.jsp is "statically" included in A.jsp
But note that this is a statical inclusion - so the dir/B.jsp code is now part of the A.jsp code.
This implies that the current jsp location in not the dir folder but the same folder as A.jsp is in
(ii)
dir/B.jsp says <jsp:include page=�C.jsp�/>.
Using the explanation in (i), in this case, the current dir of B.jsp is NOT dir, so the relative specification C.jsp resolves to C.jsp and NOT dir/C.jsp.
Compare this with:
(i) A.jsp says <jsp:include page=�dir/B.jsp�%>
(ii)dir/B.jsp says <jsp:include page=�C.jsp�/>
Here both are dynamic includes,
so (i) is including dir/B.jsp into A.jsp, dynamically.
When dir/B.jsp is executing, it current page folder IS dir, so it interprets the inclusion of C.jsp relative to dir => dir/C.jsp
There are 2 things to note here:
1. Both, page attribute of the include standard action & file attribute of the include directive are relative to the current jsp page.
2. There is a difference between the way a static include and dynamic include are handled, not just the time at which the include occurs (translation vs run-time) but in the "scope" of the inclusion.
BTW, you can avoid confusion by giving the relative path as "/x/y/z/myjsp.jsp". If you start with "/" then the path is interpreted from the root of your web application and not the current page, then there is no scope for ambiguity between a static vs dynamic include.
Hope this helps,
- ortimuS