This week's book giveaway is in the General Computing forum. We're giving away four copies of Arduino in Action and have Martin Evans, Joshua Noble, and Jordan Hochenbaum on-line! See this thread for details.
I have a web app that posts a form to another site. I need to capture the contents of the form before I post it, so I post to a servlet, capture the data, and use HttpClient to post the form to the remote URL. The problem is when I output the response like this:
OutputStream os = res.getOutputStream(); os.write(post.getResponseBody()); os.flush();
The output is relative to my server and not the actual URL so all the links are broken.
Is there a way with HttpClient to just take the response from the post have it display as it would normally? Or do I need to do some URL rewriting?
Would you care to show us one of the pages that you're trying to do this with? If you look at the HTML on those pages, are the URLs relative or absolute? If they're relative, then you'll definitely have to tack the domain part of the URL...for example, say you call myGetMethod.getResponseBodyAsString() and look at the HTML from www.techies.com/docs/index.html and see a link like this: