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

Win a copy of Java Interview Guide this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Java » JSP
Bookmark "Webpage source code" Watch "Webpage source code" New topic

Webpage source code

Bob Woodr

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 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="" target="_blank" rel="nofollow">Java forums using Java software</a> - Come and help get them started.
Ulf Dittmer

Joined: Mar 22, 2005
Posts: 42965
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:
subject: Webpage source code
It's not a secret anymore!