1

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!

1 Answer 1

3

In servlet 3.0 - yes:

public void init(FilterConfig cfg) {
   List<String> mappings = 
       cfg.getServletContext().getFilterRegistration(cfg.getFilterName())
          .getUrlPatternMappings();
}
Sign up to request clarification or add additional context in comments.

1 Comment

apart from the one you mentioned - no (perhaps some container-specific classes, but I'd prefer the param)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.