Java Reference
In-Depth Information
Absolute paths
The
path
of a URL is a path on the computer to the file that the URL
describes. For example,
/gries/Logic/Introduction.html
indicates that the hard drive of the computer whose domain name was given has
a folder (directory)
gries
; in that folder is a folder named
Logic
, and in that
folder is a file named
Introduction.html
.
The character
/
is used to separate entities on the path, regardless of the
operating system on the computer —Unix-like, Windows, or Macintosh.
If the file name is missing at the end (so that the last entity is a folder), then
a default file is chosen, usually
index.html
or
index.htm
. This default depends
on the computer on which the file resides (it can be changed). On some comput-
ers, we have seen the following defaults:
default.html
,
default.htm
,
home.html
, and
home.htm.
If the protocol is
file
, then the domain name is usually absent and the path
is the path of a file or folder on your hard drive. The form of the beginning of
such a path depends on whether a Unix-like, Windows, or Macintosh operating
system is being used. You can check this out on your own computer by loading
any html file that is on your hard drive into a browser like Netscape
Communicator or Internet Explorer and looking at the URL that is displayed.
Here are examples for the three kinds of systems:
1. Unix:
/home/profs/gries/public_html/index.html
2. Windows:
/C:/MyDocuments/test.html
3. Mac:
/ProgramLive/Course/IC/web/ICweb.htm
Relative URLs
Within an html file, one can have a relative URL, as in:
href="people/faculty/faculty.htm"
The protocol and host are those of the current html file, and the path is assumed
to be relative to the folder in which the html file appears. One can use
".."
in
the path to move up in the path of folders, as in all operating systems. For exam-
ple, if the current folder is
/gries/Logic
, then relative path
../NoLogic/-
test.html
refers to the file
/gries/NoLogic/test.html
.
Fragments
The following URL has the
fragment
#chap1
:
http://java.sun.com/index.html#chapter1
The fragment is often the name of a
target
within the file given by the URL,
but there are other uses for it. Technically, the fragment is not part of the URL.
Search WWH ::
Custom Search