There is no standard API (more, and that was pretty limited there), but it is an XML file with a standard schema. You can get it in your filter through:
filterConfig.getServletContext().getResource("/WEB-INF/web.xml");
and get from it what you want using SAX / DOM / XPath / what you have, for example
InputStream is = filterConfig.getServletContext()
.getResourceAsStream("/WEB-INF/web.xml");
DocumentBuilder builder = DocumentBuilderFactory.newInstance()
.newDocumentBuilder();
Document document = builder.parse(is);
NodeList servlets = document.getElementsByTagName("servlet");
source
share