File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Servlets and the fly likes Capturing Servlet Output Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "Capturing Servlet Output" Watch "Capturing Servlet Output" New topic

Capturing Servlet Output

Kelley Koszegi

Joined: Aug 20, 2001
Posts: 27
I have 2 servlets, servlet A and B. Servlet A is creating a query-type screen which should allow a user to enter information into a form & submit it. The form calls the doGet method in Servlet B & the query is executed by B. B displays the output. My problem is that control has been shifted to servlet B. I don't want the user to 'know' about servlet B at all. I want servlet A to communicate the doPost & capture the resulting output, parse it nicely & display the output itself. The two servlets reside on two different servers. I don't own servlet B and have no knowledge of other methods in servlet B besides the doPost. Will RMI work if the doPost method has a void return value? Is chaining the method to try here (though I thought chaining is taboo)? Is there another commonly used method?

Kelley Koszegi<br />Sun Certified Java Programmer
William Brogden
Author and all-around good cowpoke

Joined: Mar 22, 2000
Posts: 13035
Seems to me you should be able to have servlet A open a URLConnection to servlet B to submit the form data and process the response.
Kelley Koszegi

Joined: Aug 20, 2001
Posts: 27
Thank you Bill, I appreciate your response. While poking around yesterday I found references to this solution which I tried to implement. Unfortunately I could not get the parameters to the POST correctly. I finally found the answer on JGuru's site. Just in case anyone else is looking for how to correctly send parameters to a POST via a HttpUrlConnection, check out this posting at JGuru:
I agree. Here's the link:
subject: Capturing Servlet Output
It's not a secret anymore!