Servlet upgrade patch

REFACTORED code so that servlet 2.5 containers are also supported
FIXED a lot of NPEs
I would reduce the logging level here as we already know that this can naturally happen during shutdown.