Hello, help please fix SessionListener, you need to do the following: - no fields are needed in the listener; - use the session context in the listener, not the servlet.
public class MySessionListener implements HttpSessionListener { DAOFactory daoFactory = new DAOFactory(); ServletContext context = null; @Override public void sessionCreated(HttpSessionEvent event) { context = event.getSession().getServletContext(); try { context.setAttribute("connection", daoFactory.getProfileDAO()); } catch (DAOException e) { e.printStackTrace(); } } @Override public void sessionDestroyed(HttpSessionEvent event) { try { daoFactory.getProfileDAO().close(); } catch (DAOException e) { e.printStackTrace(); } }}
getProfileDAO()
method static, and save the resulting object as a session attribute, not a servlet. - enzo