You need to use getAttribute(), not getContext().
If you were to look at the servlet code generated for the page you would see:
application = pageContext.getServletContext();
So application is already the ServletContext. This should return what you need:
Connection conn = (Connection) application.getAttribute("DatabaseConnection");