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: Viewing http response (HTML) fetched with URLConnect

  1. #1
    Junior Member
    Join Date
    Aug 2013
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Viewing http response (HTML) fetched with URLConnect

    Hi, I have piece of Java code that fetches the HTML from a website. Specifically strava.com/login (but that's not really important).

    URLConnection connection = new URL("https://www.strava.com/login").openConnection();
    InputStream response = connection.getInputStream();
    System.out.println(convertStreamToString(response));

    I get a ton of text-only HTML, is it possible to somehow view this in a browser?


  2. #2
    Administrator copeg's Avatar
    Join Date
    Oct 2009
    Location
    US
    Posts
    5,318
    Thanks
    181
    Thanked 833 Times in 772 Posts
    Blog Entries
    5

    Default Re: Viewing http response (HTML) fetched with URLConnect

    Save the output to a file with a .html extension. Then open the file with your favorite web browser. Most likely many elements will render ok.

Similar Threads

  1. Replies: 22
    Last Post: June 21st, 2013, 02:11 AM
  2. HTTP post to html servlet
    By Mith in forum Java Theory & Questions
    Replies: 1
    Last Post: October 23rd, 2012, 11:18 AM
  3. erroneous whirtespace characters in http response
    By sim in forum What's Wrong With My Code?
    Replies: 1
    Last Post: February 8th, 2011, 07:43 AM
  4. How Manipulate HTTP response?
    By nikos in forum Java Networking
    Replies: 1
    Last Post: October 7th, 2010, 12:22 PM
  5. Replies: 1
    Last Post: March 31st, 2010, 09:42 PM