File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Web Component Certification (SCWCD/OCPJWCD) and the fly likes relative/absolute paths 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/absolute paths" Watch "relative/absolute paths" New topic

relative/absolute paths

Amit Ghag

Joined: May 11, 2002
Posts: 27
We say some methods do not accept relative paths. Does that mean these methods do not accept page-relative/file-relative paths but accept context-relative paths ?
Please elaborate the difference between relative and absolute paths...

peter parker
Ranch Hand

Joined: Jul 11, 2001
Posts: 69
An absolute path contains the full URL of the item being referenced. A relative path contains directions to the item relative to the HTML page.
For example:
Let's say that we have a directory structure that looks like the following
+ development
- images
- jsp
Now let's say that index.jsp is in the development folder. Index.jsp is simply a redirect page to a file called home.jsp in the jsp folder.
This redirect can be accomplished in two ways. First by using a relative path, meaning that, given the page/file current location use
../ or / (move up directory or move down directory) to access the contents of another directory. In this case, since we're trying to call home.jsp by using a relative path from index.jsp in the development folder we would say:
The other means is the absolute path, which is simply the complete URL location need to locate the page/file. In this case we would say:
hope this helps.
Amit Ghag

Joined: May 11, 2002
Posts: 27
Thanx PP,
Just one more question. How do we specify the path of the file which is in the parent directory of the development folder ( in ur example ). Do we specify it like this--
where 'testing' is in the same folder as 'development' and 'test.jsp' is a file under 'testing'.
Amit Ghag

Joined: May 11, 2002
Posts: 27
Any tips to remember which methods of the Servlet API accept only relative paths or only absolute paths as parameters ?
R K Singh
Ranch Hand

Joined: Oct 15, 2001
Posts: 5382
I am going through APIs .... till now I think only ServletRequest.getRequestDispathcher() takes relative path.
Other methods take absolute path i.e. paths starting with "/" which is taken as relative to context of the web-app.
CMIW (Correct Me if I am Wrong)

"Thanks to Indian media who has over the period of time swiped out intellectual taste from mass Indian population." - Chetan Parekh
I agree. Here's the link:
subject: relative/absolute paths
It's not a secret anymore!