• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

file://localhost

 
Neeraj Dheer
Ranch Hand
Posts: 225
  • Mark post as helpful
  • send pies
  • 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?
 
Campbell Ritchie
Sheriff
Pie
Posts: 49827
69
  • Mark post as helpful
  • send pies
  • 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.
 
Stuart Ash
Ranch Hand
Posts: 637
  • Mark post as helpful
  • send pies
  • 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
  • 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.
 
Ilja Preuss
author
Sheriff
Posts: 14112
  • Mark post as helpful
  • send pies
  • 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
  • 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.
 
Chad Clites
Ranch Hand
Posts: 134
  • Mark post as helpful
  • send pies
  • 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
  • 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
  • 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.
 
Stefan Wagner
Ranch Hand
Posts: 1923
Linux Postgres Database Scala
  • Mark post as helpful
  • send pies
  • 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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic