| Author |
Relative Path - Totally Confusing
|
Sandeep Vaid
Ranch Hand
Joined: Feb 27, 2006
Posts: 390
|
|
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
Joined: Apr 28, 2004
Posts: 128
|
|
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.
|
Thanks, Tridib
SCJP 1.4, SCWCD 1.4, SCBCD 5.0
|
 |
 |
|
|
subject: Relative Path - Totally Confusing
|
|
|