Servlet upgrade patch

REFACTORED code so that servlet 2.5 containers are also supported
FIXED a lot of NPEs