Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 2 of 2

Thread: Updation of webpage to the last modified date

  1. #1
    Junior Member
    Join Date
    May 2009
    Posts
    1
    Thanks
    0
    Thanked 1 Time in 1 Post

    Post Updation of webpage to the last modified date

    Hi,
    I needed to find the last modified date of webpage. for that i used one code but that giving default date as output.solve my pbm.

    here the code,

    // Demonstrate URLConnection. 
    import java.net.*; 
    import java.io.*; 
    import java.util.Date; 
     
    class UCDemo 
    { 
    public static void main(String args[]) throws Exception { 
    int c; 
    URL hp = new URL("http", "www.google.com", 80, "/"); 
    System.out.print(hp);
    URLConnection hpCon = hp.openConnection(); 
    System.out.println("Date: " + new Date(hpCon.getDate())); 
    System.out.println("Content-Type: " + 
    hpCon.getContentType()); 
    System.out.println("Expires: " + hpCon.getExpiration()); 
    System.out.println("Last-Modified: " + 
    new Date(hpCon.getLastModified())); 
    int len = hpCon.getContentLength(); 
    System.out.println("Content-Length: " + len); 
    if (len > 0) { 
    System.out.println("=== Content ==="); 
    InputStream input = hpCon.getInputStream(); 
    int i = len; 
    while (((c = input.read()) != -1) && (-i > 0)) { 
    System.out.print((char) c); 
    } 
    input.close(); 
    } else { 
    System.out.println("No Content Available"); 
    } 
    } 
    }
    output:
    Content-Type: null
    Expires: 0
    Last-Modified: Thu Jan 01 05:30:00 GMT+05:30 1970
    Content-Length: -1
    No Content Available

  2. The Following User Says Thank You to Revathy G For This Useful Post:

    JavaPF (May 6th, 2009)


  3. #2
    mmm.. coffee JavaPF's Avatar
    Join Date
    May 2008
    Location
    United Kingdom
    Posts
    3,336
    My Mood
    Mellow
    Thanks
    258
    Thanked 294 Times in 227 Posts
    Blog Entries
    4

    Default Re: last modified date of webpage

    Hello Revathy G,

    Welcome to the Java Programming Forums!

    Thank you for that code tutorial. Very nice first post, it works nicely
    Please use [highlight=Java] code [/highlight] tags when posting your code.
    Forum Tip: Add to peoples reputation by clicking the button on their useful posts.

Similar Threads

  1. Replies: 1
    Last Post: May 19th, 2009, 09:19 AM
  2. [SOLVED] Need to display multiple images from database on a webpage
    By raghuprasad in forum JavaServer Pages: JSP & JSTL
    Replies: 3
    Last Post: May 13th, 2009, 03:15 AM
  3. Replies: 3
    Last Post: May 8th, 2009, 01:27 PM
  4. How to Get the current date and time
    By JavaPF in forum Java Programming Tutorials
    Replies: 2
    Last Post: December 2nd, 2008, 01:55 PM

Tags for this Thread