title: Redirect to an external URL from controller action in Spring MVC
body: <p>I have noticed the following code is redirecting the User to a URL inside the project, </p>
  
  <pre><code>@RequestMapping(method = RequestMethod.POST)
  public String processForm(HttpServletRequest request, LoginForm loginForm, 
                            BindingResult result, ModelMap model) 
  {
      String redirectUrl = "yahoo.com";
      return "redirect:" + redirectUrl;
  }
  </code></pre>
  
  <p>whereas, the following is redirecting properly as intended, but requires http:// or https://</p>
  
  <pre><code>@RequestMapping(method = RequestMethod.POST)
      public String processForm(HttpServletRequest request, LoginForm loginForm, 
                                BindingResult result, ModelMap model) 
      {
          String redirectUrl = "http://www.yahoo.com";
          return "redirect:" + redirectUrl;
      }
  </code></pre>
  
  <p>I want the redirect to always redirect to the URL specified, whether it has a valid protocol in it or not and do not want to redirect to a view. How can I do that?</p>
  
  <p>Thanks,</p>