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 :
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...
Joined: Apr 28, 2004
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.