 <p>What you are now doing is getting the <code>context.getAttribute()</code> from the ServletContext itself not from the HttpServletRequest. So it should be something like this: <code>String value = (String) req.getAttribute(token)</code>. Also keep in mind .getAttribute() method returns null if no attribute of the given name exists.</p>