• 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:
  • Tim Cooke
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Liutauras Vilda
Sheriffs:
  • Jeanne Boyarsky
  • Rob Spoor
  • Bear Bibeault
Saloon Keepers:
  • Jesse Silverman
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Piet Souris
  • Al Hobbs
  • salvin francis

Relative URL specifications, JSP 1.2.1

 
Ranch Hand
Posts: 113
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have a problem with understanding the logic behind relative paths in <%@ include and <jsp:include

JSP 1.2.1

For an include directive (see
Section JSP.1.10.3) where the path is used in a file attribute, the interpretation
is relative to the JSP file or tag file. For a jsp:include action (see
Section JSP.5.4, “<jsp:include>”) where the path is used in a page attribute,
the interpretation is relative to the JSP page.



then I have this JSP 5.4

- 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.



I can't understand what exactly means that:
- <%@ include is relative to the JSP file
- <jsp:include is relative to the JSP page

Obviously it makes difference because the examples prove it, but I still can't grasp it, especially the last example.


 
Sheriff
Posts: 67596
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
"JSP file" == location on file system
"JSP page" == URL of the page
 
Stoian Azarov
Ranch Hand
Posts: 113
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
So, if I ma getting it right it goes this way:

Example:

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.



Explanation:
1. A.jsp is invoked by /A.jsp URL
2. A.jsp has <%@ file="dir/B.jsp" %> directive is relative to the file so we get /dir/B.jsp
3. B.jsp has <jsp:include page="C.jsp"/> but even though the code is in B.jsp that resides in /dir/B.jsp the actual page URL is still /A.jsp (the first invoked page) so the relative path in page attribute is created based on /A.jsp => /C.jsp

Am I wrong?
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic