Addressing resources on the web:
Resources on the web are identified using unique addresses. This unique address is known as a Uniform Resource Locator, usually abbreviated to URL. The first part of the URL indicates the protocol to be used in accessing the resource and the second part indicates the address where the resource can be found. An example of this is shown below:
https://www.open.ac.uk/Computing/Staff/I_Newton.htm
Here, http specifies that the resource is a web page and so the protocol to use is HTTP. The part after the first two slashes provides the name of the host computer, www.open. ac.uk. The remainder of the URL is known as the path and it specifies the route to the resource. In this case, it can be found in the folder Staff, a subfolder of Computing. The name of the file is I_Newton.htm and the file extension htm indicates that it is an HTML file.
All web resources are referenced using this convention. In this course, we shall concentrate on web pages; however, you should be aware that there are other forms of URL using different protocols, such as FTP for file transfer. For example:
ftp://www.open.ac.uk/Computing/downloads/stuff.doc
would indicate the location of a (mythical) file that could be downloaded from the Open University website. A file located on the local computer system would have a URL with the protocol part file. For example:
file://C:/Computing/Staff/I_Newton.htm
This indicates to the browser that it can locate the file simply by looking in the specified folder on drive C: of the local system, and does not have to access it using a protocol such as HTTP.
The URL class that has a number of constructors that allow the programmer to create URLs. The simple constructor that we saw earlier is the single argument constructor that creates a URL from its string description. For example:
URL openUniversity = new URL("https://www.open.ac.uk");
Alternatively, it is possible to set the various components of the URL individually:
URL openUniversity = new URL("http", "www.open.ac.uk", "");
Here the arguments represent the protocol, the host (that is, the computer name) and the path. Where the path is left empty, as in this example, the URL refers to the home page for this host.
It is also possible to specify the port to be used, as in the following example of invoking the URL constructor:
URL open = new URL("ftp", "ftp.open.ac.uk", 25, "/staff.txt");
This creates the URL corresponding to ftp://ftp.open.ac.uk:25/staff.txt, which can be used for FTP access to the file staff.txt on port 25 (if the FTP server is set up to permit use of this non-standard port for FTP). Note that the port number must be specified as an integer and that the path must start with a forward slash as shown.
Most of the methods within the URL class get or set the various components of the URL. For example, they can return the protocol or the host parts of the URL:
String protocol = openUniversity.getProtocol( ); String hostName = openUniversity.getHost( );
if (protocol.equals("http"))
{
...
In general, the getter methods for the URL class are more useful than the setter methods. Once a URL object has been constructed you will seldom want to change it, although you may want to change the contents of the resource to which it refers.
Java Assignment Help - Java Homework Help
Struggling with java programming language? Are you not finding solution for your Addressing resources on the web homework and assignments? Live Addressing resources on the web experts are working for students by solving their doubts & questions during their course studies and training program. We at Expertsmind.com offer Addressing resources on the web homework help, java assignment help and Addressing resources on the web projects help anytime from anywhere for 24x7 hours. Computer science programming assignments help making life easy for students.
Why Expertsmind for assignment help
- Higher degree holder and experienced experts network
- Punctuality and responsibility of work
- Quality solution with 100% plagiarism free answers
- Time on Delivery
- Privacy of information and details
- Excellence in solving java programming language queries in excels and word format.
- Best tutoring assistance 24x7 hours