determines the addressed resource by the suffix if the requests resource is the servlet itself
162149
public static Resource getConsoleResource(BeanContext context) {
        SlingHttpServletRequest request = context.getRequest();
        ResourceResolver resolver = request.getResourceResolver();
        String path = null;
        // use the resource set by a probably executed 'defineObjects' tag (supports including components)
        Resource resource = context.getAttribute("resource", Resource.class);
        if (resource == null) {
            resource = request.getResource();
        }
        if (resource != null) {
            path = resource.getPath();
        }
        // use the suffix as the resource path if the resource is not defined or references a servlet
        if (StringUtils.isBlank(path) || path.startsWith("/bin/")) {
            RequestPathInfo requestPathInfo = request.getRequestPathInfo();
            path = requestPathInfo.getSuffix();
            resource = null;
        }
        if (resource == null && StringUtils.isNotBlank(path)) {
            resource = resolver.getResource(path);
        }
        if (resource == null) {
            // fallback to the root node if the servlet request has no suffix
            resource = resolver.getResource("/");
        }
        return resource;
    }
648875
protected boolean isAccessPermitted(String resourceName) {

		boolean accessible = true;
		if (resourceName.startsWith(JawrConstant.WEB_INF_DIR_PREFIX)) {
			if (resourceName.startsWith(JawrConstant.WEB_INF_DIR_PREFIX + GRAILS_APP_DIR)
					&& resourceName.endsWith(GrailsLocaleUtils.MSG_RESOURCE_BUNDLE_SUFFIX)) {
				accessible = true;
			} else {
				accessible = false;
			}
		}

		return accessible;
	}
191709
private static int checkWildCard(final SearchableString value, final Literal suffix, final int start) {
        for (final int index : value.getIndices(suffix)) {
            if (index >= start) {
                return index;
            }
        }
        return -1;
    }
845171
def get_as_string(self, request, *args, **kwargs):
        

        value = None
        cache = None
        prefix = None
        if self.should_cache():
            prefix = "%s:%s:string" % (self.get_cache_version(),
                                self.get_cache_prefix())
            cache = router.router.get_cache(prefix)
            value = cache.get(prefix)

        if not value:
            value = super(CacheView, self).get_as_string(request, *args,
                                                         **kwargs)
            if self.should_cache() and value and \
                    getattr(self.request, '_cache_update_cache', False):
                cache.set(prefix, value, self.cache_time)

        return value
29855
protected String calculateCurrentUri(HttpServletRequest request)
			throws UnsupportedEncodingException {
		ServletUriComponentsBuilder builder = ServletUriComponentsBuilder
				.fromRequest(request);
		// Now work around SPR-10172...
		String queryString = request.getQueryString();
		boolean legalSpaces = queryString != null && queryString.contains("+");
		if (legalSpaces) {
			builder.replaceQuery(queryString.replace("+", "%20"));
		}
		UriComponents uri = null;
		try {
			uri = builder.replaceQueryParam("code").build(true);
		} catch (IllegalArgumentException ex) {
			// ignore failures to parse the url (including query string). does't
			// make sense for redirection purposes anyway.
			return null;
		}
		String query = uri.getQuery();
		if (legalSpaces) {
			query = query.replace("%20", "+");
		}
		return ServletUriComponentsBuilder.fromUri(uri.toUri())
				.replaceQuery(query).build().toString();
	}
223338
def _resource_prefix(self, resource=None):
        
        px = 'ELASTICSEARCH'
        if resource and config.DOMAIN[resource].get('elastic_prefix'):
            px = config.DOMAIN[resource].get('elastic_prefix')
        return px
1364286
private String attachRequestString(String resourceName) {

        StringBuffer result = new StringBuffer(resourceName);
        boolean firstParam = true;
        if (resourceName.indexOf('?') == -1) {
            // no params in uri yet?
            result.append('?');
        } else {
            firstParam = false;
        }

        @SuppressWarnings("unchecked")
        Map<String, String[]> params = getJsp().getRequest().getParameterMap();
        Iterator<Map.Entry<String, String[]>> it = params.entrySet().iterator();
        String[] values = null;
        while (it.hasNext()) {
            if (values == null) {
                // first iteration: check if params before so an & has to be used.
                if (!firstParam) {
                    result.append('&');
                }
            } else {
                result.append("&");
            }
            Map.Entry<String, String[]> entry = it.next();
            result.append(entry.getKey().toString()).append('=');
            values = entry.getValue();
            for (int i = 0; i < values.length; i++) {
                result.append(values[i]);
                if ((i + 1) < values.length) {
                    result.append(',');
                }
            }
        }
        return result.toString();
    }
1306506
def handle(self, handler_name, request, suffix=''):
        """"""
        return self.runtime.handle(self, handler_name, request, suffix)
620297
@Override
	protected String getContentType(String filePath, HttpServletRequest request) {
		String requestUri = request.getRequestURI();

		// Retrieve the extension
		String extension = getExtension(filePath);
		if (extension == null) {

			LOGGER.info("No extension found for the request URI : " + requestUri);
			return null;
		}

		String binContentType = (String) binaryMimeTypeMap.get(extension);
		if (binContentType == null) {

			LOGGER.info(
					"No binary extension match the extension '" + extension + "' for the request URI : " + requestUri);
			return null;
		}
		return binContentType;
	}
306780
private String getUrlPrefix( HttpServletRequest req )
    {
        StringBuilder url = new StringBuilder();
        String scheme = req.getScheme();
        int port = req.getServerPort();
        url.append( scheme );        // http, https
        url.append( "://" );
        url.append( req.getServerName() );
        if ( ( scheme.equals( "http" ) && port != 80 ) || ( scheme.equals( "https" ) && port != 443 ) )
        {
            url.append( ':' );
            url.append( req.getServerPort() );
        }
        return url.toString();
    }
922334
public void updateJspFromRequest(String servletPath, CmsFlexRequest request) {

        // assemble the RFS name of the requested jsp
        String jspUri = servletPath;
        String pathInfo = request.getPathInfo();
        if (pathInfo != null) {
            jspUri += pathInfo;
        }

        // check the file name
        if ((jspUri == null) || !jspUri.startsWith(m_jspWebAppRepository)) {
            // nothing to do, this kind of request are handled by the CmsJspLoader#service method
            return;
        }

        // remove prefixes
        jspUri = jspUri.substring(m_jspWebAppRepository.length());
        if (jspUri.startsWith(CmsFlexCache.REPOSITORY_ONLINE)) {
            jspUri = jspUri.substring(CmsFlexCache.REPOSITORY_ONLINE.length());
        } else if (jspUri.startsWith(CmsFlexCache.REPOSITORY_OFFLINE)) {
            jspUri = jspUri.substring(CmsFlexCache.REPOSITORY_OFFLINE.length());
        } else {
            // this is not an OpenCms jsp file
            return;
        }

        // read the resource from OpenCms
        CmsFlexController controller = CmsFlexController.getController(request);
        try {
            CmsResource includeResource;
            try {
                // first try to read the resource assuming no additional jsp extension was needed
                includeResource = readJspResource(controller, jspUri);
            } catch (CmsVfsResourceNotFoundException e) {
                // try removing the additional jsp extension
                if (jspUri.endsWith(JSP_EXTENSION)) {
                    jspUri = jspUri.substring(0, jspUri.length() - JSP_EXTENSION.length());
                }
                includeResource = readJspResource(controller, jspUri);
            }
            // make sure the jsp referenced file is generated
            updateJsp(includeResource, controller, new HashSet<String>(8));
        } catch (Exception e) {
            if (LOG.isDebugEnabled()) {
                LOG.debug(e.getLocalizedMessage(), e);
            }
        }
    }
399769
protected String resolveResourceContextPath(HttpServletRequest request, String resource) {
        final String resourceContextPath = this.getResourceServerContextPath();
        
        this.logger.debug("Attempting to locate resource serving webapp with context path: {}", resourceContextPath);
        
        //Try to resolve the 
        final ServletContext resourceContext = this.servletContext.getContext(resourceContextPath);
        if (resourceContext == null || !resourceContextPath.equals(resourceContext.getContextPath())) {
            this.logger.warn("Could not find resource serving webapp under context path {} ensure the resource server is deployed and cross context dispatching is enable for this web application", resourceContextPath);
            return request.getContextPath();
        }
        
        this.logger.debug("Found resource serving webapp at: {}", resourceContextPath);
        
        URL url = null;
        try {
            url = resourceContext.getResource(resource);
        }
        catch (MalformedURLException e) {
            //Ignore
        }
        
        if (url == null) {
            this.logger.debug("Resource serving webapp {} doesn't contain resource {} Falling back to the local resource.", resourceContextPath, resource);
            return request.getContextPath();
        }
        
        this.logger.debug("Resource serving webapp {} contains resource {} Using resource server.", resourceContextPath, resource);
        return resourceContextPath;
    }
926023
public void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException
    {
        PrintWriter out;
        String  title = "Index of ";
        String dirName = (String)req.getAttribute("com.ibm.servlet.engine.webapp.dir.browsing.path");
        String reqURI = (String)req.getAttribute("com.ibm.servlet.engine.webapp.dir.browsing.uri");

        // PK81387 Start

        //I believe dirName is now the local dir, not the file system path
        File dir = null;
        URL dirURL = null;
        String dirNameFileSystemPath = req.getRealPath(dirName);
        //this is a servlet, we only have access to the ServletContextFacade
        ServletContext context = getServletConfig().getServletContext();   
        boolean fileSystem = false;
        //dirNameFileSystemPath!=null is not a good enough check to determine if you're in a container
        //if we have a container and there have been jsps compiled, it gives you the directory in the workarea
        if (dirNameFileSystemPath!=null) {
            fileSystem = true;
            dirName=dirNameFileSystemPath;
            dir = new File(dirNameFileSystemPath);

            // get path to war directory
            String contextRealPath = context.getRealPath("/");
            
            int idx=dirName.lastIndexOf(contextRealPath);
            
            if (idx!=-1) {
            	// subtract the war directory from teh reqiested directory
            	String matchString=dirName.substring(idx+contextRealPath.length());
            	
            	matchString=matchString.replace(File.separator,"/");
            	
            	// Ensure matchString starts with "/" so WSUtil.resolveURI processes leading "."s
            	if (!matchString.startsWith("/")) {
            	   matchString="/"+matchString;
            	}
            	
            	// remove a trailing "/" so tthat uriCaseCheck does a vlaid check.
            	if (matchString.endsWith("/")) {
            		matchString=matchString.substring(0, matchString.length()-1);
            	}
            	     
            	// checkWEB-INF unless esposeWebInfoOnDispatch is set and we are in a dispatched request
            	boolean checkWEBINF = !WCCustomProperties.EXPOSE_WEB_INF_ON_DISPATCH || (req.getAttribute(WebAppRequestDispatcher.DISPATCH_NESTED_ATTR)==null) ;
            	
            	try {
            		
            		if (!com.ibm.wsspi.webcontainer.util.FileSystem.uriCaseCheck(dir, matchString,checkWEBINF))
            		{
                        resp.sendError(404, nls.getString("File.not.found", "File not found"));
                        return;
            		}	
            	} catch (java.lang.IllegalArgumentException exc) {
            		// Must be traversing back directories
                    resp.sendError(404, nls.getString("File.not.found", "File not found"));
                    return;
            	}
             } else {
                 // Must be traversing back directories
                 //dirNameFileSystemPath was normalized in Liberty, whereas in tWAS it contained the root path followed by whatever was entered
                 resp.sendError(404, nls.getString("File.not.found", "File not found"));
                 return;
             }
        }
        else { //container
            dirURL = context.getResource(dirName);
            if (dirURL == null) {
                resp.sendError(404, nls.getString("File.not.found", "File not found"));
                return;
            }
        }
            // PK81387 End	
            if (!reqURI.endsWith("/"))
                reqURI += '/';
    
            title += reqURI;
    
            // make sure we can access it
            if (fileSystem && !dir.canRead())
                resp.sendError(404, nls.getString("File.not.found", "File not found"));
        // set the content type
		// set the content type as UTF-8 as filenames are encoded in UTF-8
        resp.setContentType("text/html; charset=UTF-8");

        // write the output
        out = resp.getWriter();

        out.println("<HTML><HEAD><TITLE>");
        out.println(title);
        out.println("</TITLE></HEAD><BODY>");
        out.println("<H1 align=\"left\">" + title + "</H1>");
        out.println("<HR size=\"3\"><TABLE cellpadding=\"2\"><TBODY><TR bgcolor=\"#d7ffff\">");

        // output the table headers
        out.println("<TH width=\"250\" nowrap><P align=\"left\">Name</P></TH>");
        out.println("<TH width=\"250\" nowrap><P align=\"left\">Last Modified</P></TH>");
        out.println("<TH width=\"150\" nowrap><P align=\"left\">Size</P></TH>");
        out.println("<TH width=\"300\" nowrap><P align=\"left\">Description</P></TH></TR>");

        // output a row for each file in the directory
        if (fileSystem) {
            fillTableRows(dir, reqURI, out);
        } else {
            fillTableRows(context, dirName, reqURI, out);
        }

        // finish the page
        out.println("</TBODY></TABLE></BODY></HTML>");

        // close it up
        out.close();
    }
74773
@Override
    public boolean isWrapperFor(ServletRequest wrapped) {
        final ServletRequest request = getHttpServletRequest();

        if (request == wrapped) {
            return true;
        } else if (request instanceof ServletRequestWrapper) {
            return ((ServletRequestWrapper) request).isWrapperFor(wrapped);
        } else {
            return false;
        }
    }
219722
@Nonnull
  public static StringBuffer getRequestRequestURL (@Nullable final HttpServletRequest aRequest)
  {
    StringBuffer ret = null;
    if (aRequest != null)
      try
      {
        ret = aRequest.getRequestURL ();
      }
      catch (final Exception ex)
      {
        // fall through
        if (isLogExceptions ())
          if (LOGGER.isWarnEnabled ())
            LOGGER.warn ("[ServletHelper] Failed to determine request URL of HTTP request", ex);
      }
    return ret != null ? ret : new StringBuffer ();
  }
682059
public String getRequestURI()
    {
        if (WCCustomProperties.CHECK_REQUEST_OBJECT_IN_USE){
            checkRequestObjectInUse();
        }
        // Begin PK06988, strip session id of when url rewriting is enabled
        SRTServletRequestThreadData reqData = SRTServletRequestThreadData.getInstance();
        if (reqData != null && reqData.getRequestURI() == null)
        {
            String aURI = getEncodedRequestURI();
            if (aURI == null)
                return null;
            else
                reqData.setRequestURI(WebGroup.stripURL(aURI));
        }
        // 321485
        String uri = null;
        if (reqData != null)
            uri = reqData.getRequestURI();
        if (TraceComponent.isAnyTracingEnabled()&&logger.isLoggable (Level.FINE)) {  //306998.15
            logger.logp(Level.FINE, CLASS_NAME,"getRequestURI", " uri --> " + uri);
        }
        return uri;
        // End PK06988, strip session id of when url rewriting is enabled
    }
913109
@Override
    public long getLastModified(HttpServletRequest request) {
        String path;
        int idx;
        long result;

        result = -1;
        try {
            path = request.getPathInfo();
            if (path != null && path.startsWith("/get/")) {
                lazyInit(request);
                path = path.substring(5);
                idx = path.indexOf('/');
                if (idx != -1) {
                    path = path.substring(idx + 1);
                    result = engine.getLastModified(path);
                }
            }
        } catch (IOException e) {
            error(request, "getLastModified", e);
            // fall-through
        } catch (RuntimeException | Error e) {
            error(request, "getLastModified", e);
            throw e;
        }
        LOG.debug("getLastModified(" + request.getPathInfo() + ") -> " + result);
        return result;
    }