Why Servlet.getContext(String) does not return null after undeploy
The parameter to ServletContext#getContext
does not need to point to the exact URI of the context. Therefore:
- all strings that start with
/app1
will give you the context for the/app1
application, - all strings that start with
/app2
will give you the context for the/app2
application, - after you stop
/app2
, all requests for/app2
will be routed to theROOT
context. ThereforegetContext("/app2")
will return theROOT
context.