Example usage for org.apache.wicket.request Url setHost

List of usage examples for org.apache.wicket.request Url setHost

Introduction

In this page you can find the example usage for org.apache.wicket.request Url setHost.

Prototype

public void setHost(final String host) 

Source Link

Document

Sets the host name of this url

Usage

From source file:com.mastfrog.acteur.wicket.adapters.RequestAdapter.java

License:Open Source License

@Inject
public RequestAdapter(HttpEvent evt, Locale locale, Charset charset, Settings settings) {
    this.evt = evt;
    this.locale = locale;
    this.charset = charset;
    String filterPrefix = settings.getString(PathFactory.BASE_PATH_SETTINGS_KEY, "");
    String uri = evt.getRequest().getUri();
    // Adapted from ServletWebRequest's constructor
    if (filterPrefix.length() > 0 && !filterPrefix.endsWith("/")) {
        filterPrefix += "/";
    }/* w ww  . j  a va 2  s  .  co m*/
    StringBuilder sb = new StringBuilder();
    uri = Strings.stripJSessionId(uri);
    String contextPath = "";
    final int start = contextPath.length() + filterPrefix.length() + 1;
    if (uri.length() > start) {
        sb.append(uri.substring(start));
    }

    Url url = Url.parse(sb.toString(), charset, false);
    url.setPort(settings.getInt(ServerModule.PORT));
    String host = evt.getHeader(Headers.HOST);
    if (host != null) {
        url.setHost(host);
    } else {
        url.setHost(settings.getString(PathFactory.HOSTNAME_SETTINGS_KEY, "localhost"));
    }
    url.setProtocol("http");
    this.url = url;
}

From source file:org.artifactory.webapp.wicket.application.ArtifactoryWebRequest.java

License:Apache License

private Url setParameters(Url url) {
    url.setPort(httpServletRequest.getServerPort());
    url.setHost(httpServletRequest.getServerName());
    url.setProtocol(httpServletRequest.getScheme());
    return url;/*  ww w. j  a  v  a2s .  c om*/
}