Only 44 hours left in the trailboss' kickstarter!

New rewards and stretch goals. CLICK HERE!



Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

How to display content of a url by using httpurlconnection?  RSS feed

 
sharon yang
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I want to display the content of a url that I specified in my servlet using httpurlconnection class. I tried something like the following, but I always get a blank page, am I missing anything?

URL url = new URL("http://www.msn.com");
HttpURLConnection urlc = (HttpURLConnection)url.openConnection();
urlc.setRequestMethod("GET");
urlc.connect();

I know I can use something like response.redirect, but I must use HttpURLConnection.

Thanks in advance for your help.
 
Nishan Patel
Ranch Hand
Posts: 689
Eclipse IDE Java Scala
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Hi,

I think this will help you




above System.out.println gives you the content of your Page.....


 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!