What i want to do is basically pass a HTTP request from one of my spring controllers to another controller which is inside a another webapp running on another server, and get the response back.
Example of the controller which should do this.
@RequestMapping(value = "/test", method = RequestMethod.POST)
public String test(HttpServletRequest httpServletRequest) {
String result="";
//pass httpServletRequest to another webapp and set the response to result
return result;
}
One way i could do this is by reading the request headers,request body etc. and make another http post request to that server using something like http components.
But was wondering if there is a much simpler way of doing this(e.g. perhaps just pass the entire httpServletRequest object in one go to the other webapp)?
Thanks.
it depends on what you want to do. If you need to redirect the user view to the other controller/app you can simply return
or if you want to work with returned html or json ...
You can use Spring restTemplate