Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Webpage source code

 
Bob Woodr
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 245
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Ulf Dittmer
Rancher
Posts: 42967
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic