Java Networking - URL

February 9, 2018 Oclemy Java URL 1 minute, 13 seconds

Java URL

URL stands for Uniform Resource Locater.

Function of URL

  1. 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

  1. File e.g webpages, .exe files,video files, images etc.
  2. Directory.
  3. Query to Database.
  4. 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:

  1. http - Tells us the protocol we are using, HTTP. HTTP stands for HyperText Transfer Protocol.
  2. www.camposha.info : This is the host machine/server where our resource resides on.
  3. 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:

  1. 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 : http://www.camposha.info:3000/java/arraylist

Comments