• 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Jeanne Boyarsky
  • Junilu Lacar
  • Henry Wong
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Tim Cooke
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Frits Walraven
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Piet Souris
  • salvin francis
  • fred rosenberger

Relative URL specifications, JSP 1.2.1

 
Ranch Hand
Posts: 113
  • Mark post as helpful
  • send pies
  • 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: 67403
173
Mac Mac OS X IntelliJ IDE jQuery Java
  • Mark post as helpful
  • send pies
  • 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
  • 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?
 
Paddy spent all of his days in the O'Furniture back yard with this tiny ad:
Devious Experiments for a Truly Passive Greenhouse!
https://www.kickstarter.com/projects/paulwheaton/greenhouse-1
    Bookmark Topic Watch Topic
  • New Topic