Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Relative URL specifications, JSP 1.2.1

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


 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 65218
95
IntelliJ IDE Java jQuery Mac Mac OS X
  • 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?
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic