URL Information program in java


Objective:
Define a class that displays information about a file URL like its type, encoding, length, dates of creation, last modification and expiry. Additionally the class should display the request method, response message and the response code for a Web URL.

Packages used:
1.      java.net.*;    :- Package is used for creating netowork connections.
2.      java.io.*       :-Package for accessing input/output methods.

Classes used:
·         URL: Class URL represents a Uniform Resource Locator, a pointer to a "resource" on the World Wide Web.
·         URLConnection : The abstract class URLConnection is the superclass of all classes that represent a communications link between the application and a URL.
·         HttpURLConnection  :  A URLConnection with support for HTTP-specific features. (for request and response message).

Logical flow of the program:
  • Objects of classes URL,URLConnection and HttpURLConnection are created.
  • With the help of these objects URL’s type,encoding length,dates of creation,last modification and expiry.
  • HttpURLConnection’s object is used to retrieve request and response message.

Important notes:

  • To get the information about the URL (protocol,filename,hostname etc) create Class object ,else to get the data about the web page create URLConnection object(URLConnection con=url.openConnection()).


0 comments:

Copyright © 2012 OpenTechZone | Kesari Technologies |