Quantcast
Channel: Active questions tagged servlets - Stack Overflow
Viewing all articles
Browse latest Browse all 675

Excluding list of URLs from servlet filter

$
0
0

What could be the best practice for Excluding a list of URL patterns from below servlet filter?

Use case: Create a whitelist of URLs that could be skipped through the below Http servlet filter.

@WebFilter(urlPatterns = "/*")public class SanitizeReqestParamFilter implements Filter {  @Override  public void init(FilterConfig filterConfig) throws ServletException {}  @Override  public void destroy() {}  @Override  public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse, FilterChain filterChain)      throws ServletException, IOException {    // logic for sanitize the request params.    filterChain.doFilter(servletRequest, servletResponse);  }}

Note:Currently, I have a list of URLs in an enum and check if the request URL is present in that list or not.

I would like to use some other method something like,

  1. adding this list on filter registration so that it could exclude those URLs.
  2. Or have some custom annotation on the servlet that could help to identify skipped URLs.

Viewing all articles
Browse latest Browse all 675

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>