Possible Duplicate:
communication between remote servlets
Is it possible to send objects between servlets on different servers?
The issue is, when my servlet receives a http request, before sending a response, it would need to send some data to another web application (on different server), get a response, and then process the received data. However I don’t really know how to tackle the problem. Is it possible for a servlet to send a http request to another servlet, and then get the response from it?
Of course it is possible – you can create an
HttpURLConnectionin it in the same way you would do it from JavaSE. Usually what I do is, in case of an error, to forward to the client the original (second server) HTTP error code.