In my servlet I want to somehow open another URL, retrieve the entire HTML
code from it as text, change it a bit then serve this back to the browser -
Something like -
StringBuffer buf = new StringBuffer();
buf.append(openPage(http://www.test.co.uk/defaulthtml.htm)); //
openPage() just made that up - what would I use?
// manipulate the buf contents a bit here - don't ask why!
// write buf.toString() as the response
Is this possible?
many thanks & hope I've made some sense!
harry
Snyke - 21 Apr 2006 16:53 GMT
Hi Harry,
this is perfectly normal to do and there is absolutely no problem,
although you have to consider that the foreign server may take a long
time to respond or even timeout, in which case your visitor may wait
for a long time for a response.
Regards,
Christian 'Snyke' Decker
http://www.Snyke.net/blog/
jcsnippets.atspace.com - 21 Apr 2006 20:44 GMT
> In my servlet I want to somehow open another URL, retrieve the entire HTML
> code from it as text, change it a bit then serve this back to the browser -
[quoted text clipped - 11 lines]
>
> Is this possible?
Yes, this is possible.
Have a look at the following piece of source code:
http://jcsnippets.atspace.com/java/network-stuff/how-to-save-a-webpage.html
Then, change it to write the html you received back to the screen, that
should do it.
IIRC, you still need to set the mime-type prior to printing, but I'm not
sure.
Best regards,
JC
--
http://jcsnippets.atspace.com/
a collection of source code, tips and tricks