I am using tomcat-10(jakarta). According to the doc
getContext(String) return null if context not exists or restricted access. But in practice is not correct. For example I have two web application with /app1 and /app2. After running I undeploy /app2. I also checked registered MBeans with JMX and there is no registered servlet with context /app2. But when I call getContext(/app2) it returns ROOT servlet. Is it a bug or works normally?
UPDATE
For testing I just remove tomcat default ROOT web application. After removing when I call getContext method I got null if the requested context not exists. So that I think there is some missing information on the documentation or the custom implementation of Servlet