• Post Reply Bookmark Topic Watch Topic
  • New Topic

Specifying relative path

 
Sukhdev. Satwalia
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
How can specify the relative path of a file in a parent Directory?
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser Redhat VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The short answer is with ".."
Example:



The longer answer:
It's best not to create your relative links this way.
A better alternative is to use the request object's getContextPath method to determine the root of your application. This allows you to move your pages around as needed without having to fix all of the links on them.
Example:

or for pre 2.0 containers
 
Sukhdev. Satwalia
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Ben!
Can you tell me that can we use relative or context relative path with FileReader.
 
Ulf Dittmer
Rancher
Posts: 42970
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can, but in a web app you shouldn't. Relative paths imply that there's a well-defined base directory somewhere, and in a web app that's just not the case.
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser Redhat VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Rather than using FileReader, look at:
java.lang.String&41;" target="_blank" rel="nofollow">http://java.sun.com/j2ee/1.4/docs/api/javax/servlet/ServletContext.html#getResourceAsStream&40;java.lang.String&41;
 
Deepan Devadasan
Ranch Hand
Posts: 226
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
[Thread hijack removed. Ask your own questions in new topics rather than taking over someone else's.]
[ January 28, 2007: Message edited by: Bear Bibeault ]
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!