Display Home page date, Content Type, Expiration date, Last modified & Home Page Length in Java Program

Aim
To implement in java program
Display Homepage with last modified date, Expiration Date and Homepage Length
CS1404 INTERNET PROGRAMMING LABORATORY
Algorithm
Start the program for Display Homepage with last modified date, Expiration Date and Homepage Length
Get the url in the agr[0]
Assign the variable to u
By through the following function get the necessary data
obj.getContentType( )
Date(obj.getDate( )
Date(obj.getLastModified( )

obj.getExpiration( )
obj.getContentLength( )
And display it
Terminate the program for Display the Contents of Home Page

Source Code Java Program for Display the Contents of Home Page
import java.io.*;
import java.net.*;
import java.util.*;
public class Dishomcon {
public static void main(String args[]) {
for (int j=0; j < args.length; j++) {
try {
URL rl = new URL(args[0]);
URLConnection obj = rl.openConnection( );
System.out.println("Content-type: " +
obj.getContentType( ));
System.out.println("Content-encoding: " +
obj.getContentEncoding( ));
System.out.println("Last modified: " + new
Date(obj.getLastModified( )));
System.out.println("Date: " + new
Date(obj.getDate( )));
System.out.println("Expiration date: " +
new Date(obj.getExpiration( )));
System.out.println("Content-length: " +
obj.getContentLength( ));
}
catch (MalformedURLException ex) {
System.err.println(args[j] +
" is not a URL I understand");
}
catch (IOException erobj) {
System.err.println(erobj);
}
System.out.println( );
}
}
}
Output:- CS1404 INTERNET PROGRAMMING LABORATORY
Compile the program for Display the Contents of Home Page
C:\IPLAB>javac Dishomcon.java
C:\IPLAB>javac Dishomcon.java
C:\IPLAB>java Dishomcon http://172.16.0.15/default.htm
Content-type: text/html
Content-encoding: null
Last modified: Wed Sep 21 21:29:19 IST 2007
Date: Fri Sep 22 14:18:49 IST 2007’x
Expiration date: Thu Jan 01 07:29:00 IST 1970
Content-length: 16118
C:\IPLAB>