aspose file tools*
The moose likes Web Component Certification (SCWCD/OCPJWCD) and the fly likes Relative URL specifications, JSP 1.2.1 Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Web Component Certification (SCWCD/OCPJWCD)
Bookmark "Relative URL specifications, JSP 1.2.1" Watch "Relative URL specifications, JSP 1.2.1" New topic
Author

Relative URL specifications, JSP 1.2.1

Stoian Azarov
Ranch Hand

Joined: Jun 01, 2011
Posts: 113
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

Joined: Jan 10, 2002
Posts: 60992
    
  65

"JSP file" == location on file system
"JSP page" == URL of the page


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Stoian Azarov
Ranch Hand

Joined: Jun 01, 2011
Posts: 113
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?
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Relative URL specifications, JSP 1.2.1