Forums Register Login

relative path confusion

+Pie Number of slices to send: Send
Hi All,


i have a.jsp & b.jsp under root

i am including b.jsp in a.jsp like below
------------------------------------
a.jsp
-----
<%@include file="/b.jsp" %>//fine it is working

my doubt is when i do like below also it is working how?

<%@include file="../b.jsp" %>//

please anyone can explain me?

Thanks & Regards,
seetharaman
+Pie Number of slices to send: Send
The first makes it relative to the root of the webapp.
The second makes it relative to the current file.

The first, in my opinion, is a better approach.
+Pie Number of slices to send: Send
Hai Ben,

please can you explain in details?
+Pie Number of slices to send: Send
The first "/b.jsp" says to the server "Look for b.jsp in the root of this web application". In this case, it doesn't matter where a.jsp is. You could move it from "/" to "/pages/" to "/pages/directoryToHoldPageA/" or any other sub-directories and the app would still know how to find page B.jsp.
This link would only be broken if you were to move B.jsp.
You can move A.jsp to any location within the application and it would still know where to find B.jsp.

The second, is relative to the location of A.jsp.
The ".." is the symbol for parent directory.
So "../B.js" says to the server "Look one directory higher than the one that I (A.jsp) am in for a page named B.jsp". If you move either A.jsp, or B.jsp, and the move doesn't result in B.jsp being in the parent of the directory that holds A.jsp, the link will be broken.
+Pie Number of slices to send: Send
Thanks a lot BEN
Ruth Stout was famous for gardening naked. Just like this tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com


reply
reply
This thread has been viewed 1323 times.
Similar Threads
Difference JSP File & JSP Page
jsp:include
Need help: jsp: include relative path question!
include action vs. include directive
page relative vs file relative [ include action vs include directive]
More...

All times above are in ranch (not your local) time.
The current ranch time is
Mar 29, 2024 04:28:01.