Created
April 19, 2016 07:08
-
-
Save jonekdahl/563b8f1b8d67d57c1225a7bab30f46fc to your computer and use it in GitHub Desktop.
Dump servlets and filters registered in a ServletContext
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| if (getServletContext() != null) { | |
| ServletContext ctx = getServletContext(); | |
| logger.info("Context '{}':", ctx.getContextPath()); | |
| Map<String, ? extends ServletRegistration> servletRegistrations = ctx.getServletRegistrations(); | |
| for (Map.Entry<String, ? extends ServletRegistration> entry : servletRegistrations.entrySet()) { | |
| String servletName = entry.getKey(); | |
| ServletRegistration servletRegistration = entry.getValue(); | |
| logger.info(" Servlet '{}':", servletName); | |
| for (String mapping : servletRegistration.getMappings()) { | |
| logger.info(" Mapping: '{}'", mapping); | |
| } | |
| } | |
| Map<String, ? extends FilterRegistration> filterRegistrations = ctx.getFilterRegistrations(); | |
| for (Map.Entry<String, ? extends FilterRegistration> entry : filterRegistrations.entrySet()) { | |
| String filterName = entry.getKey(); | |
| FilterRegistration filterRegistration = entry.getValue(); | |
| logger.info(" Filter '{}':", filterName); | |
| for (String mapping : filterRegistration.getUrlPatternMappings()) { | |
| logger.info(" URL Mapping: '{}'", mapping); | |
| } | |
| for (String mapping : filterRegistration.getServletNameMappings()) { | |
| logger.info(" Servlet Mapping: '{}'", mapping); | |
| } | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment