class ServletContextHelper {

    public ServletMapping getResolvedServletMapping(final ServletContext servletContext, final String path) {
        Objects.requireNonNull(servletContext);
        for (ServletMapping servletMapping : servletContext.getServletMappings()) {
            String inContextPath = getPathInContext(servletContext, path);
            if (servletMapping.getUrlPattern().matcher(inContextPath).matches()) {
                return servletMapping;
            }
        }

        return null;
    }

}