permaculture playing cards*
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

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: 41108
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.

Ping & DNS - my free Android networking tools app
jQuery in Action, 2nd edition
subject: Webpage source code
Similar Threads
Creating Java classes on fly
JSP values into HTML hidden fields ? or javascript ?
Server URL call issues in jsp/struts
"Type mismatch: cannot convert from Cookie to String"
Q for Kathy & Bert