I'm not sure anyone really hit this on the head so far...
A URL is, as given earlier, a Uniform Resource Locator - it's what we colloquially call a "web address" and defines the host name and port of a server and the path to a resource on that server (including any extra query string data).
A URI is the general term given to all Resource
Identifiers. A URL is a special case of a URI, but there are others, most notably a Uniform Resource Name (URN).
URNs are primarily intended for naming of resources and defining namespaces without reference to a path in a file system. They take the form:
urn:{namespace}:{otherdata}
where {namespace} is chosen by and assigned to the organisation and {otherdata} is chosen by the organisation to sub-categorise. For example, RFC 3121 gives the example:
urn:oasis:names:tc:docbook:dtd:xml:docbook:5.0b1
This is a urn (first bit) owned by the Oasis group (second phrase) and part of their "names" namespace, residing under the category "tc:docbook:dtd:xml:docbook" with version "5.0b1".
You might ask what use this is - in practise URNs are rarely used because there is no authorative body for their administration. Unlike domain names there is no main registration process, which makes it unclear who owns what namespaces. So URLs are in fact used in many places to define a namespace where in fact perhaps a URN would be better.
One example of a URN in
J2EE is when declaring a tag library in a
JSP document (the XML variety) where you want to refer to an explicit TLD or a tag file directory. In that case you can use these:
urn:jsptld:{path}
urn:jsptagdir:{path}
where {path} is the path to the TLD or the tag directory respectively.
So URNs do have limited use locally within applications, but their widespread use is much reduced. I don't know why many of the
servlet methods talk about URIs when nearly always they actually mean URLs - perhaps they are left open for the possibility of using URNs etc. in the future?
[ May 08, 2006: Message edited by: Charles Lyons ]