/** * Returns a list of filters to be included for given path. It first checks whether the filter * is included, and then checks whether the filter is excluded for given path. * <p> * Filter included URL pattern must not be null. Filter excluded URL pattern can be null. * * @param servletContext * @param path * @return */ public List<FilterMapping> getFilterMappingsForPath(final ServletContext servletContext, final String path) { Objects.requireNonNull(servletContext); String inContextPath = getPathInContext(servletContext, path); List<FilterMapping> filterMappings = new ArrayList<>(); for (FilterMapping filterMapping : servletContext.getFilterMappings()) { if (filterMapping.getUrlPattern().matcher(inContextPath).matches()) { if (filterMapping.getUrlExcludePattern() != null) { if (!filterMapping.getUrlExcludePattern().matcher(inContextPath).matches()) { filterMappings.add(filterMapping); } } else { filterMappings.add(filterMapping); } } } return filterMappings; }