How about:

Url relative = Url.parse(getRequest().getContextPath());
String full = getRequestCycle().getUrlRenderer().renderFullUrl(relative);

Dan


On Wed, Apr 3, 2013 at 5:44 AM, Andrea Del Bene <[email protected]>wrote:

> Hi,
>
> do you know the best way to get the base URL for our Wicket application?
> For example
>
> "http://www.mysite.com/**myapplication<http://www.mysite.com/myapplication>
> "
>
> I'm using the following code at the moment:
>
>
> protected CharSequence extractBaseUrl(Request request) {
>         Url originalUrl = request.getOriginalUrl();
>         CharSequence baseUrl = originalUrl.getProtocol() + "://" +
> originalUrl.getHost() +
>                                 ":" + originalUrl.getPort() +
> request.getContextPath();
>
>
>         return baseUrl;
>     }
>
> ------------------------------**------------------------------**---------
> To unsubscribe, e-mail: 
> users-unsubscribe@wicket.**apache.org<[email protected]>
> For additional commands, e-mail: [email protected]
>
>

Reply via email to