This may be a stupid question, but i am trying to create a "global" database connection object for my web app using a servletContextListener and setting it as a context attribute. I have a plain old bean that i want to get the connection from the servletContext but cannot. Inside my bean i have:
...
Connection con = (Connection) getServletContext().getAttribute("DbStudents");
...
but get the compile error: "Cannot resolve symbol method getServletContext()"
Is this because the servletContext can only be accessed from a
Servlet?