Alex Rivera | Logout

Forward a servlet request to another server

Asked 2012-06-02T07:16:28.283
12

Java Servlet API can forward requests to another path within the same server (identical host:port). But, forwarding to a different host:port — like proxy do — is another story.

I've tried to do that with Jersey Client, adapting the ServletRequest — method, headers, mediatype and body — to a Jersey ClientRequest (with a different base uri), making the call, and adapting back the Jersey ClientResponse — method, headers, mediatype and body — to the ServletResponse.

Adapting those manually seems wrong to me.

Isn't there a pure Servlet API solution? Or an HTTP client capable of adapting requests back and forth when changing the host:port?

Edit
Report

1 Answer

0

As far as I understand You need to send requests from Servlet and get response from other server into yours, may be you need a HTTP Client (Overview) for that.
This question might also help you.

answered 2012-06-02T07:44:29.910

Your Answer