How to redirect an external URL in Play Framework 2.0 (Java)

Redirecting to the internal URL is possible using the redirect () method in the controller.

public static Result index() { return redirect(routes.Application.tasks()); } 

However, I want to redirect the external URL to the controller. redirect (String) only accepts internal URLs as a parameter.

What I need is the equivalent of a standard Java Java servlet, for example,

 request.sendRedirect(String url) 
+7
source share
1 answer

Sometimes a simple solution just ... works:

 return redirect("http://stackoverflow.com/questions/10962694"); 

It is also worth using other available redirects , such as

  • seeOther(String url)
  • movedPermanently(String url)
  • temporaryRedirect(String url)

etc.

+19
source

All Articles