Java Networking - URL
URL stands for Uniform Resource Locater.
Function of URL
- Point to a resource in the World Wide Web. Thus you can use a URL to locate a resource in the web.
For example a URL like
http://camposha.info/java points you to a java document in our site.
Example Resources to be located by URL
- File e.g webpages, .exe files,video files, images etc.
- Query to Database.
- Search Engine. etc.
Parts of a URL
Let's say we have some URL like this
http://www.camposha.info/java/arraylist. This URL has the following parts:
http- Tells us the protocol we are using, HTTP. HTTP stands for HyperText Transfer Protocol.
www.camposha.info: This is the host machine/server where our resource resides on.
java/arraylist- Points us to the particular resource or information in that machine. Note that this may either be a file or a complex query to say database or some dynamic calculation. In other words it can be a static resource or be generated on the fly. This part of the url is called the path component of the URL.
Also optionally the URL can have:
- Port - Port number for the TCP connection to be made. If it is not specified just like we haven't in our URL, then the default Port is used, This port for HTTP is normally
80. Otherwise the port can also be specified as follows :