Servlet upgrade patch

REFACTORED code so that servlet 2.5 containers are also supported
FIXED a lot of NPEs
FIXED it, indeed the clause was not correct.