title: GetServletContext returning null in a class that extends HttpServlet
body: <p>So I have a class that extends HttpServlet and I was trying to access variables set in different class that has implemented ServletContextListener. </p>
  
  <p>However the following line of code in the class that extends HttpServlet is giving me the NullPOinterException:</p>
  
  <pre><code>SomeObject x =  getServletContext().getAttribute("x");
  </code></pre>
  
  <p>I don't understand why this is happening. Any ideas?</p>