Win a copy of AWS Security this week in the Cloud/Virtualization forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Jeanne Boyarsky
  • Junilu Lacar
  • Henry Wong
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Tim Cooke
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Frits Walraven
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Piet Souris
  • salvin francis
  • fred rosenberger

relative/absolute paths

 
Greenhorn
Posts: 27
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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...
 
Ranch Hand
Posts: 69
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Amit,
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:
redirect(/jsp/home.jsp);
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:
redirect(http://myServer.com/development/jsp/home.jsp);
hope this helps.
-PP
 
Amit Ghag
Greenhorn
Posts: 27
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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--
redirect("../testing/test.jsp");
where 'testing' is in the same folder as 'development' and 'test.jsp' is a file under 'testing'.
 
Amit Ghag
Greenhorn
Posts: 27
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Any tips to remember which methods of the Servlet API accept only relative paths or only absolute paths as parameters ?
 
Ranch Hand
Posts: 5390
1
Spring Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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)
 
It wasn't my idea to go to some crazy nightclub in the middle of nowhere. I just wanted to stay home and cuddle with this tiny ad:
Devious Experiments for a Truly Passive Greenhouse!
https://www.kickstarter.com/projects/paulwheaton/greenhouse-1
    Bookmark Topic Watch Topic
  • New Topic