expert
expert

Reputation: 30095

Is there way to query "url-pattern" property from Java code of servlet filter?

Is there way to obtain "url-pattern" property from Java code of servlet filter ? I know I can pass same pattern in servlet init params but it seems redundant.

Thanks!

Upvotes: 1

Views: 441

Answers (1)

Bozho
Bozho

Reputation: 597046

In servlet 3.0 - yes:

public void init(FilterConfig cfg) {
   List<String> mappings = 
       cfg.getServletContext().getFilterRegistration(cfg.getFilterName())
          .getUrlPatternMappings();
}

Upvotes: 3

Related Questions