Last updated 2004-06-28 by Roedy
Green ©1996-2004 Canadian Mind Products
Java definitions: 0-9 A B C D E F G H I J K L M N O P Q R S T U V W X Y Z
You are here : home : Java Glossary : U words : URI.
URIs must be constructed with the characters 0-9 a-z A-Z $-_.+!*'(), Other characters must be URI-encoded, e.g. space becomes %20 (because space = 0x20) or +, ;/?:@=& need be quoted only when they are not being used for their reserved purpose. For details see the Blooberry Essay. java.net.URLEncoder.encode will encode strings and java.net.URLDecoder.decode will decode strings. Earlier versions of Java were missing the decode and you had to roll your own.
You can specify IPv4 but not IPv6 numeric IP addresses in URIs.
Please report examples of other URI formats you see so I can add them to this list.
| Types of URI | |
|---|---|
| Example | Notes |
| AIM: | America Online 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 | 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:////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://24.87.56.253: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. |
| 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. |
In windows 95/98/ME/NT/2000/XP, *.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:
home |
Canadian Mind Products | |||
| mindprod.com IP:[24.87.56.253] | ||||
| Your IP:[80.134.30.163] | ||||
| You are visitor number 3771. | ||||
| Please send errors, omissions and suggestions | ||||
| to improve this page to Roedy Green. | ||||
| You can get a fresh copy of this page from: | or possibly from your local J: drive mirror: | |||
| http://mindprod.com/jgloss/uri.html | J:\mindprod\jgloss\uri.html | |||