• 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

file://localhost

 
Ranch Hand
Posts: 225
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi again!!!

I have come across some code which does something like:



This code is used to get a Stream to a file on the filesystem using tomcat. What does 'file://localhost' resolve to??? Is this a standard way of referring to some particular directory?
 
Marshal
Posts: 79151
377
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
As far as I know, "file://localhost" is the opposite of "http://www." It means you are looking for some resource information or data on your own computer, and displaying that in html or similar format.
 
Ranch Hand
Posts: 637
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Open a local folder on your machine thru your browser, and go clicking in the subfolders. Observe the URL in the browser.
 
Neeraj Dheer
Ranch Hand
Posts: 225
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Ritchie: I understand that. It maps to some file on the local system. But which file/directory? It cant point to some arbitrary directory.

Stuart: The URL doesnt show up that. i get the 'C;/.. ' or whatever path that way.

I am told it points to the 'Temp' directory, but i am not sure this is right.
 
author
Posts: 14112
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
As far as I know, it points to the file "./localhost/some_dir/some_file.ext".

So there probably is a "localhost" directory in the working directory of tomcat.
 
Neeraj Dheer
Ranch Hand
Posts: 225
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Ilja,

I have tried this in Websphere as well and it works, so it is not a tomcat thing.

From what I can see, file://localhost resolves to the context root of all the web apps, like the webapps directory in tomcat.
 
Ranch Hand
Posts: 134
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Localhost maps to 127.0.0.1 in your hosts file, which is the software loopback interface of your system (Localhost, not the hosts file)
[ November 23, 2005: Message edited by: C Clites ]
 
Neeraj Dheer
Ranch Hand
Posts: 225
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
ok...So, it resolves to the 'root' directory of the system.

For Ex:- on my windows machine file://localhost/ resolves to 'C:/' .
What happens if i have more than one drives/partitions? Have been told that it resolves to the drive on which the calling application resides.

I have not tried this on Unix, but am assuming it wil still resolve to '/'. Or will it resolve to the user's 'home' directory?
 
Chad Clites
Ranch Hand
Posts: 134
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I'm not sure how it works on anything other than Windows, but on a Windows box, it will resolve to the partition on which the OS is installed. My guess is that it would be the same for all operating systems for cross platform compatability.
 
Ranch Hand
Posts: 1923
Scala Postgres Database Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Neeraj Dheer:
I have not tried this on Unix, but am assuming it wil still resolve to '/'. Or will it resolve to the user's 'home' directory?



It resolves to the 'root' directory / , not home.
 
She'll be back. I'm just gonna wait here. With this tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic