Response.sendRedirect(URL) is NOT working when I call from an external application. I am working on two enterprise applications parallelly.
Application A: http://localhost:9080/abc
Application B: http://localhost:8080/xyz
Angular App which is retrieving response from Application B: http://localhost:9000
Currently, I am in App-A and making AJAX call to App-B. When service hit to App-B RestController, then I want to redirect to http://localhost:9000 in browser from RestController of App-B.
I tried the below approach in RestController of App-B, but it doesn't work. Still, browser URL is http://localhost:9080/abc which is point to App-A:
@RequestMapping(value = "/redirect", method = RequestMethod.GET)
public void method(HttpServletResponse httpServletResponse) {
httpServletResponse.setHeader("Location", "http://localhost:9000");
httpServletResponse.setStatus(302);
}
@RequestMapping(value = "/redirect", method = RequestMethod.GET)
public ModelAndView method() {
return new ModelAndView("redirect:http://localhost:9000");
}
@RequestMapping(value = "/redirect", method = RequestMethod.GET)
public void method(HttpServletResponse httpServletResponse) {
httpServletResponse.sendredirect("http://localhost:9000");
}
I need to pass data from App-A to App-B before I launch angular application. So, I am making AJAX call from App-A. I can not directly call to Angular app from App-A with passing query param. I have to pass data through the header or request body. Could you help with this?