• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

relative path confusion

 
Seetharaman Venkatasamy
Ranch Hand
Posts: 5575
Eclipse IDE Java Windows XP
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser Redhat VI Editor
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Seetharaman Venkatasamy
Ranch Hand
Posts: 5575
Eclipse IDE Java Windows XP
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hai Ben,

please can you explain in details?
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser Redhat VI Editor
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Seetharaman Venkatasamy
Ranch Hand
Posts: 5575
Eclipse IDE Java Windows XP
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks a lot BEN
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic