aspose file tools*
The moose likes JSP and the fly likes Webpage source code Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSP
Bookmark "Webpage source code" Watch "Webpage source code" New topic
Author

Webpage source code

Bob Woodr
Greenhorn

Joined: Feb 09, 2006
Posts: 3
Is there any way to get a webpages source code using jsp? For example I want my jsp page to get the source code of lets say www.javaranch.com and write it to a file, how can I do this? thanks.
Scott Dunbar
Ranch Hand

Joined: Sep 23, 2004
Posts: 245
Your best bet would be to look at Apache Commons HttpClient library. This makes it very simple to get a URL. It also handles things like cookies and authentication.


<a href="http://forums.hotjoe.com/forums/list.page" target="_blank" rel="nofollow">Java forums using Java software</a> - Come and help get them started.
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 42951
    
  72
And of you want to process the page you got, have a look into HttpUnit (on SourceForge), which will give you a DOM view of the page. That way you can use the DOM API or XPath to get at the contents of the page.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Webpage source code