Gets a resource from a servlet request

@param request the servlet request
@return the resource or null if not found
@throws java.net.MalformedURLException thrown when malformed URL.
508836
public AbstractFileResolvingResource getResource(HttpServletRequest request) throws MalformedURLException {
        String servletPath;
        String pathInfo;
        boolean included = request.getAttribute(RequestDispatcher.INCLUDE_REQUEST_URI) != null;

        if (included) {
            servletPath = (String) request.getAttribute(RequestDispatcher.INCLUDE_SERVLET_PATH);
            pathInfo = (String) request.getAttribute(RequestDispatcher.INCLUDE_PATH_INFO);

            if (servletPath == null && pathInfo == null) {
                servletPath = request.getServletPath();
                pathInfo = request.getPathInfo();
            }
        } else {
            servletPath = request.getServletPath();
            pathInfo = request.getPathInfo();
        }

        String pathInContext = addPaths(servletPath, pathInfo);
        return getResource(pathInContext);
    }
633090
protected String getMethod(HttpServletRequest request) {
        String uri = request.getRequestURI();
        String q = uri.substring((request.getContextPath()+request.getServletPath()).length()+1);
        int i = q.indexOf(".");
        String method = null;
        if(i>0){
            method = q.substring(i+1);
        }
        return method;
    }
1280750
public static String getRequestParameterValue(final HttpServletRequest request, final String key) {
		String[] values = getRequestParameterValues(request, key);
		return values == null || values.length == 0 ? null : values[0];
	}
1312793
public URL getResource(String path) throws MalformedURLException {

		URL url = null;
		File file = new File(baseDir + path);
		if (file.exists()) {
			url = file.toURI().toURL();
		}
		return url;
	}
685295
public static String getContextRequestUri(HttpServletRequest request) {
		String requestUri = request.getRequestURI();
		String contextPath = request.getContextPath();
		int cpLen = contextPath.length();
		if(cpLen > 0) {
			assert requestUri.startsWith(contextPath);
			return requestUri.substring(cpLen);
		} else {
			return requestUri;
		}
	}
781216
public String getCrumb(ServletRequest request) {
        String crumb = null;
        if (request != null) {
            crumb = (String) request.getAttribute(CRUMB_ATTRIBUTE);
        }
        if (crumb == null) {
            crumb = issueCrumb(request, getDescriptor().getCrumbSalt());
            if (request != null) {
                if ((crumb != null) && crumb.length()>0) {
                    request.setAttribute(CRUMB_ATTRIBUTE, crumb);
                } else {
                    request.removeAttribute(CRUMB_ATTRIBUTE);
                }
            }
        }

        return crumb;
    }
309235
public static String getAppURL(HttpServletRequest request) {
		StringBuffer url = new StringBuffer();
		int port = request.getServerPort();
		if (port < 0) {
			port = 80; // Work around java.net.URL bug
		}
		String scheme = request.getScheme();
		url.append(scheme);
		url.append("://");
		url.append(request.getServerName());
		if ((scheme.equals("http") && (port != 80)) || (scheme.equals("https") && (port != 443))) {
			url.append(':');
			url.append(port);
		}
		return url.toString();
	}
233811
public static String getContext(final HttpServletRequest request) {
    String context = request.getContextPath();
    if ((context == null) || (context.equals("."))) {
      context = "";
    }

    return context;
  }
375470
public static String getFullUrl(HttpServletRequest request) {

        if (request.getQueryString() == null) {
            return request.getRequestURI();
        }

        return request.getRequestURI() + "?" + request.getQueryString();
    }
1212030
public static boolean isSourceMapRequest(HttpServletRequest request) {
		String pathInfo = request.getPathInfo();
		boolean result = false;
		if (pathInfo != null && isSourceMapsEnabled(request)) {
			if (pathInfo.endsWith(ILayer.SOURCEMAP_RESOURCE_PATH)) {
				result = true;
			}
		}
		return result;
	}
60650
public static Map<String, String[]> getParams(ServletRequest request) {
		final Map<String, String[]> map = request.getParameterMap();
		return Collections.unmodifiableMap(map);
	}
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());
    }
1071148
public GetImageResponse getImage(GetImageRequest request) {
        checkNotNull(request, "request should not be null.");
        checkStringNotEmpty(request.getImageId(), "request imageId should not be empty.");
        InternalRequest internalRequest =
                this.createRequest(request, HttpMethodName.GET, IMAGE_PREFIX, request.getImageId());
        return invokeHttpClient(internalRequest, GetImageResponse.class);
    }
1062980
public static String baseUriOf(final HttpServletRequest request) {
        final StringBuffer requestUrl = request.getRequestURL();
        return requestUrl != null
                ? requestUrl.substring(0, requestUrl.indexOf(request.getServletPath()))
                : "";
    }
1090845
private String getPathExtension(HttpServletRequest request) {
		String extension = UriUtils.extractFileExtension(request.getRequestURI());		
		return extension != null ? "." + extension : "";
	}
998075
private IDataSource getDataSource(HttpServletRequest request) throws DataSourceNotFoundException {
        String contextPath = request.getContextPath();
        String requestURI = request.getRequestURI();

        String path = contextPath == null
                ? requestURI
                : requestURI.substring(contextPath.length());

        if (path.equals("/") || path.isEmpty()) {
            final String baseURL = FragmentRequestParserBase.extractBaseURL(request, config);
            return new IndexDataSource(baseURL, dataSources);
        }

        String dataSourceName = path.substring(1);
        IDataSource dataSource = dataSources.get(dataSourceName);
        if (dataSource == null) {
            throw new DataSourceNotFoundException(dataSourceName);
        }
        return dataSource;
    }
1041913
public static String getRequestURI(final HttpServletRequest request) {
		return (String) request.getSession(true).getAttribute(STORE_URI_KEY);
	}