Returns the base URL of the print servlet.

@param httpServletRequest the request
775557
protected final StringBuilder getBaseUrl(final HttpServletRequest httpServletRequest) {
        StringBuilder baseURL = new StringBuilder();
        if (httpServletRequest.getContextPath() != null && !httpServletRequest.getContextPath().isEmpty()) {
            baseURL.append(httpServletRequest.getContextPath());
        }
        if (httpServletRequest.getServletPath() != null && !httpServletRequest.getServletPath().isEmpty()) {
            baseURL.append(httpServletRequest.getServletPath());
        }
        return baseURL;
    }
1041913
public static String getRequestURI(final HttpServletRequest request) {
		return (String) request.getSession(true).getAttribute(STORE_URI_KEY);
	}
1329367
public static int getPage(final HttpServletRequest request) {
        int ret = 1;
        final String p = request.getParameter("p");
        if (Strings.isNumeric(p)) {
            try {
                ret = Integer.parseInt(p);
            } catch (final Exception e) {
                // ignored
            }
        }

        if (1 > ret) {
            ret = 1;
        }

        return ret;
    }
1367697
protected String getScriptUri(HttpServletRequest request) {
        /*
         * Log some debug information for https://issues.apache.org/jira/browse/GROOVY-861
         */
        if (logGROOVY861) {
            log("Logging request class and its class loader:");
            log(" c = request.getClass() :\"" + request.getClass() + "\"");
            log(" l = c.getClassLoader() :\"" + request.getClass().getClassLoader() + "\"");
            log(" l.getClass()           :\"" + request.getClass().getClassLoader().getClass() + "\"");
            /*
             * Keep logging, if we're verbose. Else turn it off.
             */
            logGROOVY861 = verbose;
        }

        //
        // NOTE: This piece of code is heavily inspired by Apaches Jasper2!
        // 
        // http://cvs.apache.org/viewcvs.cgi/jakarta-tomcat-jasper/jasper2/ \
        //        src/share/org/apache/jasper/servlet/JspServlet.java?view=markup
        //
        // Why doesn't it use request.getRequestURI() or INC_REQUEST_URI?
        //

        String uri = null;
        String info = null;

        //
        // Check to see if the requested script/template source file has been the
        // target of a RequestDispatcher.include().
        //
        uri = (String) request.getAttribute(INC_SERVLET_PATH);
        if (uri != null) {
            //
            // Requested script/template file has been target of 
            // RequestDispatcher.include(). Its path is assembled from the relevant
            // javax.servlet.include.* request attributes and returned!
            //
            info = (String) request.getAttribute(INC_PATH_INFO);
            if (info != null) {
                uri += info;
            }
            return applyResourceNameMatcher(uri);
        }

        //
        // Requested script/template file has not been the target of a 
        // RequestDispatcher.include(). Reconstruct its path from the request's
        // getServletPath() and getPathInfo() results.
        //
        uri = request.getServletPath();
        info = request.getPathInfo();
        if (info != null) {
            uri += info;
        }

        /*
         * TODO : Enable auto ".groovy" extension replacing here!
         * http://cvs.groovy.codehaus.org/viewrep/groovy/groovy/groovy-core/src/main/groovy/servlet/GroovyServlet.java?r=1.10#l259
         */

        return applyResourceNameMatcher(uri);
    }
6332
protected String getProtocolByHttpContentType(HttpServletRequest httpServletRequest) {
        if (StringUtil.isEmpty(httpServletRequest.getContentType())) {
            throw new InvalidRequestException("Rpc protocol invalid");
        }
        String protocol = httpServletRequest.getContentType().split(";")[0];
        if (protocol == null) {
            protocol = NaviCommonConstant.DEFAULT_PROTOCAL_CONTENT_TYPE;
            if (LOG.isDebugEnabled()) {
                LOG.debug("Content-type set to default value "
                        + NaviCommonConstant.DEFAULT_PROTOCAL_CONTENT_TYPE);
            }
        } else {
            protocol = protocol.toLowerCase();
        }
        return protocol;
    }
462003
public static String getAbsoluteUrl(SlingHttpServletRequest request, String url) {
        if (!isExternalUrl(url) && url.startsWith("/")) {
            String scheme = request.getScheme().toLowerCase();
            url = scheme + "://" + getAuthority(request) + url;
        }
        return url;
    }
56727
public static String getLog(final HttpServletRequest httpServletRequest) {
        if (null == httpServletRequest) {
            return "request is null";
        }

        final String indents = "    ";
        final StringBuilder logBuilder = new StringBuilder("Request [").append(Strings.LINE_SEPARATOR);

        logBuilder.append(indents).append("method=").append(httpServletRequest.getMethod()).append(",").append(Strings.LINE_SEPARATOR);
        logBuilder.append(indents).append("URL=").append(httpServletRequest.getRequestURL()).append(",").append(Strings.LINE_SEPARATOR);
        logBuilder.append(indents).append("contentType=").append(httpServletRequest.getContentType()).append(",").append(Strings.LINE_SEPARATOR);
        logBuilder.append(indents).append("characterEncoding=").append(httpServletRequest.getCharacterEncoding()).append(",").append(Strings.LINE_SEPARATOR);
        logBuilder.append(indents).append("local=[").append(Strings.LINE_SEPARATOR);
        logBuilder.append(indents).append(indents).append("addr=").append(httpServletRequest.getLocalAddr()).append(",").append(Strings.LINE_SEPARATOR);
        logBuilder.append(indents).append(indents).append("port=").append(httpServletRequest.getLocalPort()).append(",").append(Strings.LINE_SEPARATOR);
        logBuilder.append(indents).append(indents).append("name=").append(httpServletRequest.getLocalName()).append("],").append(Strings.LINE_SEPARATOR);
        logBuilder.append(indents).append("remote=[").append(Strings.LINE_SEPARATOR);
        logBuilder.append(indents).append(indents).append("addr=").append(getRemoteAddr(httpServletRequest)).append(",").append(Strings.LINE_SEPARATOR);
        logBuilder.append(indents).append(indents).append("port=").append(httpServletRequest.getRemotePort()).append(",").append(Strings.LINE_SEPARATOR);
        logBuilder.append(indents).append(indents).append("host=").append(httpServletRequest.getRemoteHost()).append("],").append(Strings.LINE_SEPARATOR);
        logBuilder.append(indents).append("headers=[");
        final Enumeration<String> headerNames = httpServletRequest.getHeaderNames();
        final StringBuilder headerLogBuilder = new StringBuilder();
        if (null != headerNames) {
            logBuilder.append(Strings.LINE_SEPARATOR);
            while (headerNames.hasMoreElements()) {
                final String name = headerNames.nextElement();
                final String value = httpServletRequest.getHeader(name);
                headerLogBuilder.append(indents).append(indents).append(name).append("=").append(value);
                headerLogBuilder.append(Strings.LINE_SEPARATOR);
            }
            headerLogBuilder.append(indents);
        }
        headerLogBuilder.append("]");
        logBuilder.append(headerLogBuilder.toString());

        logBuilder.append(Strings.LINE_SEPARATOR).append("]");

        return logBuilder.toString();
    }
1118046
private String getBaseUrl(String pUrl, String pServletPath) {
        String sUrl;
        try {
            URL url = new URL(pUrl);
            String host = getIpIfPossible(url.getHost());
            sUrl = new URL(url.getProtocol(),host,url.getPort(),pServletPath).toExternalForm();
        } catch (MalformedURLException exp) {
            sUrl = plainReplacement(pUrl, pServletPath);
        }
        return sUrl;
    }
851806
protected String buildUrl(AbstractBaseRequest request) throws AbstractCosException {
		String endPoint = this.config.getCosEndPoint();
		int appId = this.cred.getAppId();
		String bucketName = request.getBucketName();
		String cosPath = request.getCosPath();
		cosPath = CommonPathUtils.encodeRemotePath(cosPath);
		return String.format("%s/%s/%s%s", endPoint, appId, bucketName, cosPath);
	}
28772
public static final String getRequestUriWithoutContextPath(HttpServletRequest request) {
        String uri = request.getRequestURI().substring(request.getContextPath().length());
        if (!uri.isEmpty()) {
            return uri;
        } else {
            return "/";
        }
    }
271082
public String getRequestURL()
    {
    	HttpServletRequest httpReq = getRequest();
    	if (httpReq==null)
    		return null;
    	else
    		return httpReq.getRequestURL().toString();
    }
233811
public static String getContext(final HttpServletRequest request) {
    String context = request.getContextPath();
    if ((context == null) || (context.equals("."))) {
      context = "";
    }

    return context;
  }
1161608
@RequestMapping(
            path = "/api",
            method = RequestMethod.GET,
            produces = {"application/hal+json", "application/json"}
    )
    public HalRepresentation getHomeDocument(final HttpServletRequest request) {
        final String homeUrl = request.getRequestURL().toString();
        return new HalRepresentation(
                linkingTo()
                        .self(homeUrl)
                        .single(linkBuilder("search", "/api/products{?q,embedded}")
                                .withTitle("Search Products")
                                .withType("application/hal+json")
                                .build())
                        .build()
        );
    }
917892
public static String getUrl(final HttpServletRequest request) {
    try {
      final StringBuffer sb = request.getRequestURL();
      if (sb != null) {
        return sb.toString();
      }

      // Presumably portlet - see what happens with uri
      return request.getRequestURI();
    } catch (Throwable t) {
      return "BogusURL.this.is.probably.a.portal";
    }
  }
351754
@Override
    public String url() {
        String url = "";
        if (!StringUtils.isEmpty(baseUrl())) {
            url = baseUrl() + path();
        } else {
            if (!StringUtils.isEmpty(properties.getProperty(Constants.DEFAULT_PROPERTY_URL))) {
                url = properties.getProperty(Constants.DEFAULT_PROPERTY_URL);
            }
            if (testConfig != null && (!StringUtils.isEmpty(testConfig.url()))) {
                url = testConfig.url();
            }
            if (!StringUtils.isEmpty(JvmUtil.getJvmProperty(Constants.JVM_CONDUCTOR_URL))) {
                url = JvmUtil.getJvmProperty(Constants.JVM_CONDUCTOR_URL);
            }
        }
        return url;
    }
832071
public static String getDomain(HttpServletRequest request) {

		if (request == null) {
			return null;
		}

		return UrlUtils.resolveDomain(request.getServerName());
	}
1329923
public String getRequestInfo(HttpServletRequest request) {
        return String.format("URI: %s; Scheme: %s; Host: %s; Port: %s; Origin: %s; Method: %s",
                             request.getRequestURI(),
                             request.getScheme(),
                             request.getServerName(),
                             request.getServerPort(),
                             request.getHeader("Origin"),
                             request.getMethod());
    }