OK, so the basic problem (as I understand it) is that you can't BOTH write to an output stream from a
servlet and use sendRedirect to redirect the URI to a different server. So what you will have to do is:
(1) Build your xml document as a
String.
(2) Use an HTTPURLConnection to open a connection to the PHP program and send the String you just built.
(3) Get a String back from the HTTPURLConnection and then place that on the output of your servlet.
By the way -- might I say that this is a horrible architecture for your web site. This will work, but the response time may not be good. If your servlet is the one that the user hits from their URL, then it should be doing the processing -- it may be in your interest to write your own code to just redo everything the PHP program does.
Kyle