Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / General / April 2006

Tip: Looking for answers? Try searching our database.

Can this be done from a servlet?

Thread view: 
harry - 21 Apr 2006 16:35 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 -

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


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2009 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.