This week's book giveaway is in the Agile and other Processes forum.
We're giving away four copies of The Mikado Method and have Ola Ellnestam and Daniel Brolund on-line!
See this thread for details.
The moose likes Servlets and the fly likes Is there a way to read HTML into a string from a URL Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


Win a copy of The Mikado Method this week in the Agile and other Processes forum!
JavaRanch » Java Forums » Java » Servlets
Reply Bookmark "Is there a way to read HTML into a string from a URL" Watch "Is there a way to read HTML into a string from a URL" New topic
Author

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

Fritz Largosa
Ranch Hand

Joined: Sep 12, 2005
Posts: 70
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

Joined: Jan 10, 2002
Posts: 56192
    
  13

Yes, but as this has nothing to do with JSP, I'll first move this to the Servlets forum.


[Smart Questions] [JSP FAQ] [Books by Bear] [Bear's FrontMan] [About Bear]
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 56192
    
  13

Investigate the URL and URLConnection classes, or save yourself some trouble and look up the HttpClient project.
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 56192
    
  13

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

Joined: Sep 12, 2005
Posts: 70
Ok I will look that up, I can use either servlet or JSP. Thanks.
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 35241
    
    7
It could be as simple as:



Android appsImageJ pluginsJava web charts
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 56192
    
  13

In a JSP, look into <c:import>.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Is there a way to read HTML into a string from a URL
 
Similar Threads
Instantiating URL from Html Content Stored in a String
sending back a URL
Reading HTML using JAVA
Passing a HTML String into the JEditorPane rather than the File name ???
parsing url content into string