Wicket: Relative to absolute URL or get base URL

Gilean picture Gilean · Apr 12, 2010 · Viewed 15.7k times · Source

If I have a relative path to a static asset (flash/blah.swf), what is the best way to programmatically convert this to an absolute URL (http://localhost/app/flash/blah.swf)? Or what is the best way to get the base URL of the Wicket application? I've tried using RequestUtils.toAbsolutePath but it doesn't seem to work reliably and is frequently throwing exceptions. This needs to work on all servers the app is deployed to.

Answer

Manuel Manhart picture Manuel Manhart · Jun 19, 2013

For Wicket 6 it is

String absoluteUrl = RequestCycle.get().getUrlRenderer().renderFullUrl(Url.parse("my-relative-url.html"));