Sorry to bust up your day with this, but I've spent ages trawling the web for an answer and I'm completely stuck!
In a web app, I'm using RequestDispatcher to send a request from servlet_A to servlet_B.
In servlet_B, I run some code which generates a simple String value which is returned as a response to servlet_A.
In servlet_A, I need to convert the response from servlet_B into a simple String value, and this is the bit that I'm stuck with. How do I process the response from servlet_B as a simple String in servlet_A?
I think I need to use PrintWriter to parse the response in servlet_A, and I've searched the web for an example of this, but all I can find are examples showing how to use PrintWriter to send a response or to output data to the screen.
I would be very grateful if someone could help me with this.
You don't. Once you forward, that's the end of the line.
If you need a string from other code, you shouldn't be calling it as a servlet, but as a simple method. Why do you feel you need to go through all the complications of calling a servlet rather than a method just to get s string back?
Thanks for such a quick reply! In my current design, servlet_B re-directs to a Jsp to allow user entry, and the inputted value is returned to servlet_A. If I can't catch the response from servlet_B, I need to come up with a different architecture!
Bear, thanks for being a hero! I'll mark this as resolved.