• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Relative Path - Totally Confusing

 
Ranch Hand
Posts: 392
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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...
 
Ranch Hand
Posts: 128
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
No more fooling around. Read this tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic