• Post Reply Bookmark Topic Watch Topic
  • New Topic

Read a URL?

 
Anthony Smith
Ranch Hand
Posts: 285
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I want a function that can take a URL and then I can print out its html....
A full URL. ie www.ibm.com
I know it can be done but how?
 
Ronald Francis
Ranch Hand
Posts: 30
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Take a look at java.net.HttpURLConnection.
 
Erick Jones
Ranch Hand
Posts: 38
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can use the java.net.URL object to open an InputStream.
URL url = new URL("http://www.ibm.com");
InputStream stream = url.openConnection();
Erick
 
Shawn Bayern
Author
Ranch Hand
Posts: 160
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can also use the standard JSTL <c:import> tag in your JSP pages to import a relative or absolute URL.
 
Anthony Smith
Ranch Hand
Posts: 285
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
ok, I got it to work but I have firewall problems. What is my workaround?
URL url = new URL("http://www.ibm.com");
InputStream inp = url.openStream();
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!