You have a privilege to create a quiz (QnA) related to this subject and obtain creativity score...
Http Access or World Wide Web
Let us discuss even more exiting subject: Access to World Wide Web managed by Hypertext Transfer Protocol (HTTP).
Here is a brief overview of basic classes involved in HTTP access.
The java.net package includes URL and its associated classes providing a simplified interface to the World Wide Web (WWW) on the Internet.
The URL class represents a Uniform Resource Locator - a reference to an object on the World Wide Web.
This is a constant object, once it is created, its fields cannot be changed.
URL object can be created from a string like "http://aol.com".
After creating a URL object we can use its openStream() method to create an InputStream. Then we engage a usual scenario of using Input streams by creating a proper input stream for proper type of information.
For example to read a web page, which is html/text by its nature, we would create a BufferedReader stream out of InputStream.
The URLConnection class represents an active connection to an object pointed by URL.
The class constructor starts a URL connection to the specified URL.
The connect() method of this class provides the second phase of the process making finally the URL connection.
Was it clear so far?
This can be used for writing data to a specified (by URL) address.
In this scenario, we create URL object first.
Then we create a URLConnection object using the openConnection() method.
We prepare the connection for output using the setDoOutput() method.
Then we can get output stream for the connection and write data out.
The data format should be supported by HTTP protocol.
We can use the URLEncoder class that turns Strings of text into x-www-form-urlencoded format.
We can use the URLStreamHandler class for creating URL streams for particular protocol types.
Assignments:
1. Answer QnAs below.
2. Create 3 more QnAs and email as 3.2.5.HttpAccess.Your.Name.txt to dean@ituniversity.us