1

I ve done some researches but couldn't find any question or answer that could help me,

so my probleme is as below :

I have a controller that redirects to an external link :

@controller("person")
publi class PersonController(){

    @RequestMapping(value="redirect",method=RequestMethod.POST)
    public String redirectToExternalLink(params...){
        String url = "https://externalHost.com/doSomthing";
        response.sendRedirect(url);
    }
}

after going through this method, I find my self face to a 404 error Page not Found, when I check the link I ve been redrected to I find :

www.mydomainName.com/doSomthing

As you can see, the external domain name is replaced by mine, I ve tried also this :

response.setHeader("Location",url);
response.sendRedirect(url);

same issue.

is it a configuration that I should do on tomcat ? or there is a way to solve it ?

thanks

Todd
  • 30,472
  • 11
  • 81
  • 89
Mohamed Nabli
  • 1,629
  • 3
  • 17
  • 24
  • That code won't compile as-is, can you include the actual code you are having problems with? – Todd Jan 08 '17 at 15:43

2 Answers2

0

Your code

response.sendRedirect(url);

is correct. However, I would double check the url redirected to. I would also run the code in debug mode and check if

response.sendRedirect(url);

is executed in the first place.

Velusamy Velu
  • 372
  • 1
  • 14
0

Please refer to this question, Redirect to an external URL from controller action in Spring MVC. If you encounter the common problem.

For my case, it was a network configurations issue (URL rewriting).

Mohamed Nabli
  • 1,629
  • 3
  • 17
  • 24