File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Java in General and the fly likes file://localhost Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "file://localhost" Watch "file://localhost" New topic
Author

file://localhost

Neeraj Dheer
Ranch Hand

Joined: Mar 30, 2005
Posts: 225
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

Joined: Oct 13, 2005
Posts: 37950
    
  22
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

Joined: Oct 07, 2005
Posts: 637
Open a local folder on your machine thru your browser, and go clicking in the subfolders. Observe the URL in the browser.


ASCII silly question, Get a silly ANSI.
Neeraj Dheer
Ranch Hand

Joined: Mar 30, 2005
Posts: 225
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

Joined: Jul 11, 2001
Posts: 14112
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.


The soul is dyed the color of its thoughts. Think only on those things that are in line with your principles and can bear the light of day. The content of your character is your choice. Day by day, what you do is who you become. Your integrity is your destiny - it is the light that guides your way. - Heraclitus
Neeraj Dheer
Ranch Hand

Joined: Mar 30, 2005
Posts: 225
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

Joined: Aug 16, 2005
Posts: 134
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

Joined: Mar 30, 2005
Posts: 225
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

Joined: Aug 16, 2005
Posts: 134
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

Joined: Jun 02, 2003
Posts: 1923

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.


http://home.arcor.de/hirnstrom/bewerbung
 
wood burning stoves
 
subject: file://localhost
 
Similar Threads
localhost missing to the WebsPhere
about networking
Reading files in a directory of the jar file
Calling constants from another file in JS
namespace