I have a problem with my first HttpServlet.
I have 2 HttpServlet (S1 & S2) on 2 different computers.
what I want them to do is:
- S1 changes values of some parameters in HttpServletRequest that it recieved, then sends modified request to S2.
- S2 does something with HttpServletRequest sent by S1, then sends HttpServletResponse to S1.
Anyone can show me what I have to do!
because one servlet needs to invoke a http request to the second servlet, i imagine you would need something like a http client inside the first servlet to originate a request to the second servlet. see also: HttpClient - HttpClient Home
If all servlet1 does is modify the request before sending it on to servlet2, it sounds like you should just use a ServletFilter, instead of having a whole separate servlet.
The Essentials of Filters
Except Servlet 2 is on a different machine, so is part of a different web app.
It all smacks of web services gone a bit strange, but each to their own I suppose.
You're right, Tolls, I missed that... d'oh!
Unless the original post leaves out some compelling reason to do this with a servlet, I'd say an Apache reverse proxy is probably the easier solution... depending on the skills at hand, I guess.