• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Relative Path - Totally Confusing

 
Sandeep Vaid
Ranch Hand
Posts: 392
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Which of the following holds true always ?

Relative paths are of 2 types :
A) Starting with a / -> This means that it is relative to the content_root of the web applciation.
Example :

res.sendRedirect("/html/index.html);
It will be interpreted as :

<context_root>/html/index.html

B) Starting without a / -> In this case it is relative to the request URL.
Please let me know with example what how do we know the request URL.
res.sendRedirect("html/index.html);

Does these above 2 holds true in every case ?

How about in doGet():

File f = new File("ABC.jar");

as the path doesn't starts with a /, it should be B) senario of Relative path so it should be converted to
<request URL>/ABC.jar
but ALAS it doesn;t.

Moreover what is the absolute path?

I request you to provide me with as many different examples as you can.
This doubt of mine is really not getting resolved from any resource...
 
Tridib Samanta
Ranch Hand
Posts: 128
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The relative path concept varies from context to context.

Whenever you are talking about File, the path is relative to the current directory from where you are running the web-server. Like, if you run the tomcat from c:\tomcat\bin and try to use new File("abc.jar"), you must place the "abc.jar" file in "c:\tomcat\bin".

But, in case of any response.sendRidirect(), the relative path is as you specified.
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic