Connection con = (Connection) e.getServletContext().getAttribute("con"); try { con.close(); } catch (SQLException ignored) { } // close connection
Connection con = // create connection e.getServletContext().setAttribute("con", con);