Clever users can even invent new types on the fly, and register them in the java.protocol.handler.pkgs system property. You can specify IPv4 but not IPv6 numeric IP addresses in URIs.
| Allowable Characters | URL vs URI |
| Formats | getResource |
| Relative vs Absolute | Learning More |
| Component Parts | Links |
URLs never automatically armour their parameters, where URIs sometimes do.
| Types of URI | |
|---|---|
| Example | Notes |
| AIM: | America on-line Instant Messenger, an instant mail service. |
| dbaw://Gloria:8889 | Symantec dbAnywhere. Gloria is the name of a local computer on the net with an IP in your HOSTS file. 8889 is the port. |
| dns://mynameserver.com/mindprod.com | JNDI specification of a site for which you want DNS (Domain Name Server) information. You feed these strange double-barrelled URLs to javax.naming.directory.Attributes.DirContext.getAttributes(). See JNDI for more details. |
| file:///C|/mydir/myfile.txt | Old style local file URN. Most browsers today use the C: rather than C| style. To get at a local file you must encode the name in a strange way. That example started out life as C:\mydir\myfile.txt . Use Netscape 4.79 to load a file and it will tell you the URL-encoded name on the top line. JNLP does not like this form. |
| file://localhost/C:/mydir/myfile.txt | This is a variant of the local file scheme above, popular in more recent browsers. This is the form JNLP likes. |
| file:///C:/other/mydir/myfile.txt | Count’em three slashes after the file: Used to get at a file on local hard disk C:\other\mydir\myfile.txt It is like the localhost form, with the host field left blank. |
| file:////other/mydir/myfile.txt | Count’em four slashes after the file: Used to get at a file on remote LAN drive \\other\mydir\myfile.txt It is like the localhost form, with the host field and the drive field left blank. |
| file:/localhost//C|/mydir/myfile.txt | This is the long form for accessing a local file. It could also be used to access a file on a computer attached via a LAN, by substituting localhost with the host name. |
| ftp://roedy:sesame@www.hans.org/downloads/getit.zip | for File Transfer Protocol downloads. roedy
is the userid, and sesame is the password. For
anonymous FTP, you can leave out the userid and password: ftp://www.hans.org/downloads/getit.zip
FTP for Java client support |
| gopher://gopher.someplace.edu | Gopher protocol is an endangered species largely replaced by HTTP. |
| http://www.hans.org/index.html#FLUORIDE | Hypertext Transfer Protocol. It gives the site name and the document name within that site, and the spot within that document. Unfortunately, showDocument in older versions of Opera cannot handle a #FLOURIDE extension. |
| http://roedy:sesame@www.hans.org/membersonly/goodies.html | Hypertext Transfer Protocol. It gives userid, password, the site name, the document name within that site. |
| http://65.110.21.43:80/index.html | Hypertext Transfer Protocol, using an IP and port address 80. It gives the site name and the document name within that site. |
| myfile.txt | Relative URI. Usually this would get you a file on the mother web site from which the current page was loaded, relative to the web page being viewed. You can’t use relative URIs directly. You must convert them to absolute URIs using the URI context constructor. An absolute URI must have a complete http: domain, filename and optional #REF. getDocumentBase and getCodeBase are useful in converting relative to absolute URIS. I know of no tools to go the other way to find the shortest relative URI to express a given absolute URI in a given context. Browsers must convert relative URL links to absolute ones before sending the request to the server. |
| https://www.hans.org/index.html | Secure HTTP for SSL (encrypted secure socket) connections, only work inside
Netscape.
SSL: to learn how to add support in browsers that don’t directly support https |
| icq: | ICQ instant messaging service. Also allows file transfer. |
| jar:file:///C|/bar/baz.jar!/com/foo/Quux.class | Local jar file. In JDK1.2+ there are jar URIs for getting at the contents of the individual member of a local jar. |
| jar:http://www.foo.com/bar/baz.jar!/com/foo/Quux.class | Jar on server. In JDK1.2+ there are jar URIs for getting at the contents of the individual member of a remote jar. |
| jdbc:BorlandBroker://193.174.106.43:1600/sample,user,password | Typical JDBC connection. |
| mailto:someone@somedomain.com | |
| n2p: | Net To Phone. A scheme where you use the Internet to telephone people without Internet connections. |
| nap: | Napster MP3 file-sharing protocol. Allows peer-to-peer file transfers with a minimum of setup fuss. |
| news:comp.lang.java.programmer | Newsgroup. Needs a newsreader. |
| pnm: | Real Audio streaming format |
| rlogin: | remote login. |
| rmi://server:1099 | rmi access the server. |
| rmi:Strawberry | rmi access an LDAP object. |
| rtsp: | Real Tme Streaming Protocol |
| telnet://melvyl.ucop.edu/ | telnet |
| urn:isbn:096139210x | ISBN book number |
However, I have not found any built-in way to convert an absolute URI to the most compact relative representation given a context. You would use this to correct HTML references to their most compact canonical form.
| HTTP: URI Component Parts | ||
|---|---|---|
| http://roedy@www.mindprod.com:80/products/abc.html?type=all&colour=brown#DEF | ||
| Example Part | URI.method | Name |
| http://roedy@www.mindprod.com:80/products/abc.html?type=all&colour=brown#DEF | toString | url |
| http | getProtocol | protocol, scheme |
| roedy@www.mindprod.com:80 | getAuthority | authority |
| roedy | getUserInfo | Userinfo, email address |
| www.mindprod.com | getHost | host |
| mindprod.com | - | domain |
| 80 | getPort | port, nearly always 80 for http. |
| /products/abc.html | getPath | path, URI: Uniform Resource Identifier |
| type=all&colour=brown | getQuery | query, used in CGI queries to pass data to the server. |
| DEF | getRef | ref, fragment, reference, target. Not technically part of the URI. Anchor in document to point to. |
| fragment | getFragment | part after #, ref, fragment, reference, target. Not technically part of the URI. Anchor in document to point to. |
In W95/W98/Me/NT/W2K/XP/W2K3/Vista, *.url files let you create short cuts (bookmarks) to web files on the Internet or your local disk. They are just little text files stored on your disk. If you peek inside one, they look something like this:
![]() |
and suggestions to improve this page to Roedy Green : | ||
| Canadian Mind Products | |||
| mindprod.com IP:[65.110.21.43] | |||
| Your face IP:[38.103.63.16] | ![]() | ||
| You are visitor number 32,533. | |||
| You can get a fresh copy of this page from: | or possibly from your local J: drive (Java virtual drive/Mindprod website mirror) | ||
| http://mindprod.com/jgloss/uri.html | J:\mindprod\jgloss\uri.html | ||