title: How to find the base URL of the current webapp in Spring?
body: <p>I'd like to find the absolute URL of the webapp in Spring, from the Controller. I'm aware of JSTL c:url, but I need this info from inside the Controller. </p>
  
  <pre><code>@Controller
  public class AuthorizeController {
  
      @Autowired
      private Authorizer auth;
  
      @RequestMapping("/auth")
      public String sendToAuthorization() {        
          String baseUrl = "http://localhost:8080/tasks/";
          return "redirect:" +  auth.getAuthorizationUrl(baseUrl);
      }
  
  }
  </code></pre>
  
  <p>As you can see the baseUrl is hardcoded, and I could provide it to the Authorizer class via Spring configuration, but I am sure that it's possible to get this information from Spring within the Controller. I tried to google "spring mvc url" and could not find a way to solve this problem.</p>