• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

current JSP page v/s current JSP file!!

 
Ranch Hand
Posts: 153
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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).]
 
Ranch Hand
Posts: 150
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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).]
 
author
Posts: 3252
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic