aspose file tools*
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
Author

Capturing Servlet Output

Kelley Koszegi
Greenhorn

Joined: Aug 20, 2001
Posts: 27
Hello,
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?
TIA,
--Kkoszegi

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

Joined: Mar 22, 2000
Posts: 12806
    
    5
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.
Bill
Kelley Koszegi
Greenhorn

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: http://www.jguru.com/forums/view.jsp?EID=470766
Thanks,
--KKoszegi
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Capturing Servlet Output