I need to use URL-mapping for my servlet which is set in web.xml. Currently I can read the mappings with the following code in the processRequest function.
Iterator<String> urlMappings = this.getServletContext().getServletRegistration(MyServletClass.class.getSimpleName()).getMappings().iterator();
while (urlMappings.hasNext()) {
System.out.println(urlMappings.next());
}
However getServletContext function is not static and therefore I cannot read it without an instance of the servlet. That is also OK but if there is a way to do this with only static functions I will prefer that solution. Any help?
I am using Tomcat 8.0.3 and JDK 1.8