• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Is there a way to read HTML into a string from a URL

 
Fritz Largosa
Ranch Hand
Posts: 70
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
For example I want a method which accepts a url and returns the html source of the target page. Anybody know if this can be done? Any documentations I can read or sample codes? I do not seem to find any information regarding this.

Pseudocode:

String html_source = method_get_html_source("http://www.my_page/page1.html");
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 65216
95
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes, but as this has nothing to do with JSP, I'll first move this to the Servlets forum.
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 65216
95
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Investigate the URL and URLConnection classes, or save yourself some trouble and look up the HttpClient project.
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 65216
95
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Or, are you really trying to do this from a JSP rather than with java code? (and without java code in a JSP which is a no-no)
 
Fritz Largosa
Ranch Hand
Posts: 70
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ok I will look that up, I can use either servlet or JSP. Thanks.
 
Ulf Dittmer
Rancher
Posts: 42968
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It could be as simple as:

 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 65216
95
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In a JSP, look into <c:import>.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic