Example usage for javax.servlet.http HttpServletRequest getRequestURL

List of usage examples for javax.servlet.http HttpServletRequest getRequestURL

Introduction

In this page you can find the example usage for javax.servlet.http HttpServletRequest getRequestURL.

Prototype

public StringBuffer getRequestURL();

Source Link

Document

Reconstructs the URL the client used to make the request.

Usage

From source file:com.krawler.filter.ReuqestListenerForDB.java

@Override
public void requestInitialized(ServletRequestEvent sre) {
    HttpServletRequest request = (HttpServletRequest) sre.getServletRequest();
    String path = request.getRequestURL().toString();
    String subdomain = null;/*ww w .j a va  2  s.  c o m*/
    if ((subdomain = extractSubdomain(path, pattern)) != null) {
        CompanyContextHolder.setCompanySubdomain(subdomain);
    } else if ((subdomain = request.getParameter(COMPANY_PARAM)) != null) {
        CompanyContextHolder.setCompanySubdomain(subdomain.trim());
    } else if ((subdomain = request.getParameter(COMPANY_SUBDOMAIN)) != null) {
        CompanyContextHolder.setCompanySubdomain(subdomain.trim());
    } else if (request.getParameter(COMPANY_ID) != null) {
        CompanyContextHolder.setCompanyID(request.getParameter(COMPANY_ID));
    } else if (request.getParameter(USER_ID) != null) {
        CompanyContextHolder.setUserID(request.getParameter(USER_ID));
    } else if (path.contains("deskeraCRMMOB_V1.jsp") && (subdomain = request.getParameter("d")) != null) {// handle case for iphone user authentication
        CompanyContextHolder.setCompanySubdomain(subdomain.toLowerCase().trim());
    } else {
        clearCompanySubdomain();
    }
    logger.debug("Current subdomain : " + subdomain);
}

From source file:com.blackducksoftware.integration.hub.bamboo.HubBambooServlet.java

private URI getUri(final HttpServletRequest request) {
    final StringBuffer builder = request.getRequestURL();
    if (request.getQueryString() != null) {
        builder.append("?");
        builder.append(request.getQueryString());
    }//  ww w  .  ja  v a  2  s  .  c om
    return URI.create(builder.toString());
}

From source file:cec.easyshop.storefront.security.impl.DefaultGuestCheckoutCartCleanStrategy.java

@Override
public boolean checkWhetherURLContainsCheckoutPattern(final HttpServletRequest request) {
    return getCheckoutURLPattern().matcher(request.getRequestURL().toString()).matches();
}

From source file:org.apache.hadoop.gateway.dispatch.AbstractGatewayDispatch.java

@Override
public URI getDispatchUrl(HttpServletRequest request) {
    StringBuffer str = request.getRequestURL();
    String query = request.getQueryString();
    if (query != null) {
        str.append('?');
        str.append(query);//w w  w  .  j a  v  a 2  s.  c om
    }
    URI url = URI.create(str.toString());
    return url;
}

From source file:info.rmapproject.webapp.controllers.ExceptionHandlingController.java

/**
 * Handles object not found exceptions./*from   w w w .  j  a  v a  2  s.c o m*/
 *
 * @param exception the exception
 * @param req the original HTTP request
 * @return the error page
 */
@ExceptionHandler({ RMapDiSCONotFoundException.class, RMapAgentNotFoundException.class,
        RMapEventNotFoundException.class, RMapObjectNotFoundException.class }) //    RMapStatementNotFoundException.class,
public String objectNotFoundError(Exception exception, HttpServletRequest req) {
    logger.error(exception.getMessage(), exception);
    if (req.getRequestURL().toString().contains("/" + WIDGET_VIEW)) {
        return "objectnotfoundwidget";
    } else {
        return "objectnotfound";
    }

}

From source file:org.valens.bamboo.servlets.AdminServlet.java

private URI getUri(HttpServletRequest request) {
    StringBuffer builder = request.getRequestURL();
    if (request.getQueryString() != null) {
        builder.append("?");
        builder.append(request.getQueryString());
    }//from www  .j  a va  2  s .  c o  m
    return URI.create(builder.toString());
}

From source file:foo.domaintest.action.RequestModule.java

/** Provides the request URL up to but not including the query string. */
@Provides/*from   w w  w.  ja v a 2s .co m*/
@RequestData("url")
String provideRequestUrl(HttpServletRequest request) {
    return request.getRequestURL().toString();
}

From source file:sp.CASController.java

private String getBaseUrl(HttpServletRequest servletRequest) {
    String requestUrl = servletRequest.getRequestURL().toString();
    try {/*from  w  w  w.  j a  v a  2  s .c om*/
        URLBuilder urlBuilder = new URLBuilder(requestUrl);
        urlBuilder.setUsername(null);
        urlBuilder.setPassword(null);
        urlBuilder.setPath(null);
        urlBuilder.getQueryParams().clear();
        urlBuilder.setFragment(null);
        return urlBuilder.buildURL();
    } catch (MalformedURLException e) {
        log.error("Couldn't parse request URL, reverting to internal default base URL: {}", requestUrl);
        return "http://localhost:8080";
    }
}

From source file:com.intel.podm.rest.HttpServletRequestValidator.java

private String getRequestLine(HttpServletRequest servletRequest) {
    return format("%s %s HTTP/1.1\n\r", servletRequest.getMethod(), servletRequest.getRequestURL());
}

From source file:com.enonic.cms.server.service.dwr.DwrServletWrapper.java

private void setContentType(HttpServletRequest req, HttpServletResponse res) {
    String url = req.getRequestURL().toString();

    if (StringUtils.endsWith(url, ".js")) {
        res.setContentType("text/javascript");
    }/*from  ww  w . j a  v a  2  s  .co  m*/
}