| Author |
current JSP page v/s current JSP file!!
|
ashok khetan
Ranch Hand
Joined: Jul 29, 2001
Posts: 153
|
|
hi! the statements given below are from JSP spec1.2....I didn't get the difference between 'current JSP page' and 'current JSP file'. Can u help me pl?? ---------- JSP.4.4-->The page attribute of both the jsp:include and the jsp:forward actions are interpreted relative to the current JSP page, while the file attribute in an include directive is interpreted relative to the current JSP file. ---------- thanks! ashok. [This message has been edited by ashok khetan (edited October 22, 2001).]
|
 |
Tim Duncan
Ranch Hand
Joined: Aug 20, 2001
Posts: 150
|
|
The examples they give further down the page illustrate the point, although you need to read them carefully. Here's how I understand it ... First the examples, from the JSP 1.2 Spec (page 78) Example 1. 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" Example 2. 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". Example 3. 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". Example 4. 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". Now in all four cases after the first statement the current file is "dir/B.jsp". In Examples 2 and 3 the current page is also "dir/B.jsp" so both jsp:include and <%@ include ...%> have the same effect. However in Examples 1 and 4 the current page is "A.jsp", so the jsp:include in Example 4 gets "C.jsp" (i.e. relative to the current page "A.jsp"), while the <%@ include ...%> in Example 1 gets "dir/C.jsp" (i.e. relative to the current file "dir/B.jsp"). There, that's a lot clearer .... isn't it?  [This message has been edited by Tim Duncan (edited October 22, 2001).]
|
 |
Peter den Haan
author
Ranch Hand
Joined: Apr 20, 2000
Posts: 3252
|
|
With "current JSP page" it means the page as it exists in a virtual path on the server at request time. For example, in "http://www.peterdenhaan.com/myapp/example.jsp" I can include "http://www.peterdenhaan.com/servlets/foobar" using < jsp:include page="../foobar" flush="true"/>. With "current JSP file" it means the JSP source file on disk at compile time. I would not be able to include the foobar servlet using a static include < @include file="../foobar"> simply because there is no "foobar" file sitting there at all, it's just a virtual path on the server. - Peter
|
 |
 |
|
|
subject: current JSP page v/s current JSP file!!
|
|
|