Saving Page Output to variable for processing

Hello!

I have a servlet that calls (via response.setHeader; can also use response.Redirect) another web site, which returns/displays XML on the browser. I'd like to save that XML into a variable on the server so that I can parse it and save it to (Oracle) DB.

I don't know if there's a servlet function I can call to request the page and save it w/o displaying on the browser. I can then post to the browser the results only.

Can someone help?

Thx!

[482 byte] By [delphosbeana] at [2007-11-27 11:06:41]
# 1

instead of doing the redirect you can use the Apache Jakarta Commons HttpClient project to send a HTTP request to the other web application and retrieve the response. You can then parse the response and send the results to the browser.

tolmanka at 2007-7-29 13:17:07 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 2

I ended up defining a URL object and passing that to a BufferedReader, like this:

URL myUrl = new URL("http://a.url.com");

BufferedReader in = new BufferedReader(new InputStreamReader(myUrl.openStream()));

...then I process line by line with

while ((inputLine = in.readLine()) != null) {

// do my stuff...

}

I just posted this simple solution to help another newbie that may stumble upon it.

This case is closed.

Thx!

delphosbeana at 2007-7-29 13:17:07 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...