Java Reference
In-Depth Information
If the remote resource is XML, the fragment identifier is an XPointer. Some sources
refer to the fragment part of the URL as a “section”. Java rather unaccountably refers to
the fragment identifier as a “Ref ”. Fragment identifier targets are created in an HTML
document with an id attribute, like this:
<h3 id="xtocid1902914">Comments</h3>
This tag identifies a particular point in a document. To refer to this point, a URL includes
not only the document's filename but the fragment identifier separated from the rest of
the URL by a # :
http://www.cafeaulait.org/javafaq.html#xtocid1902914
Technically, a string that contains a fragment identifier is a URL refer‐
ence , not a URL. Java, however, does not distinguish between URLs
and URL references.
Relative URLs
A URL tells a web browser a lot about a document: the protocol used to retrieve the
document, the host where the document lives, and the path to the document on that
host. Most of this information is likely to be the same for other URLs that are referenced
in the document. Therefore, rather than requiring each URL to be specified in its en‐
tirety, a URL may inherit the protocol, hostname, and path of its parent document (i.e.,
the document in which it appears). URLs that aren't complete but inherit pieces from
their parent are called relative URLs. In contrast, a completely specified URL is called
an absolute URL . In a relative URL, any pieces that are missing are assumed to be the
same as the corresponding pieces from the URL of the document in which the URL is
found. For example, suppose that while browsing http://www.ibiblio.org/javafaq/java‐
tutorial.html you click on this hyperlink:
<a href="javafaq.html">
The browser cuts javatutorial.html off the end of http://www.ibiblio.org/javafaq/java‐
tutorial.html to get http://www.ibiblio.org/javafaq/ . Then it attaches javafaq.html onto
the end of http://www.ibiblio.org/javafaq/ to get http://www.ibiblio.org/javafaq/java‐
faq.html . Finally, it loads that document.
If the relative link begins with a / , then it is relative to the document root instead of
relative to the current file. Thus, if you click on the following link while browsing http://
www.ibiblio.org/javafaq/javatutorial.html :
<a href="/projects/ipv6/">
the browser would throw away /javafaq/javatutorial.html and attach /projects/ipv6/ to
the end of http://www.ibiblio.org to get http://www.ibiblio.org/projects/ipv6/ .
Search WWH ::




Custom Search