Is it possible to write a Servlet that will send request to some PHP page and then read the response generated by that PHP page? Response should contain attached "doc" file. Receiving that "doc" file is what I'm interested in. Is there any guidelines on how to do such thing?
I don't even need HttpURLConnection in order to open a stream to the specified .doc file on the Internet if I know its absolute URL address.
But, in this case I have an PHP page that dinamically generates .doc file as a byte stream I want my servlet to record that stream. I'm not sure what datas I have to read before the stream starts, i.e. I don't know where the stream begins.? Note: When I use browser, PHP response causes my browser to popup the "Save As" dialog.
Go read the documentation for HttpClient. It will allow you to simulate everything that a browser does from within your servlet code. You could also retrieve it using the HttpUrlConnection as Jeroen mentioned.
Once you get it into your servlet, you can do whatever you want with it.