/* * To change this template, choose Tools | Templates * and open the template in the editor. */ package cl.puc.ing.kegan.grupo9.controller; import java.io.*; import java.sql.SQLException; import java.util.ArrayList; import java.util.logging.Level; import java.util.logging.Logger; import javax.servlet.*; import javax.servlet.http.HttpSessionEvent; import javax.servlet.http.HttpSessionListener; /** * * @author fegil */ public class Inicializacion implements ServletContextListener, HttpSessionListener { // implementar el método context init requerido public void contextInitialized(ServletContextEvent sce) { } // implementar el método context destroy requerido public void contextDestroyed(ServletContextEvent sce) { } public void sessionCreated(HttpSessionEvent arg0) { try { TagDataAccessObject tdao = new TagDataAccessObject(); ArrayList tagsPadre = new ArrayList(); tagsPadre.addAll(tdao.getLevelTags(3)); tagsPadre.add(0, "Todos"); arg0.getSession().setAttribute("t_padres", tagsPadre); for (int i = 1; i < tagsPadre.size(); i++) { ArrayList tagsHijos = new ArrayList(); String name = (String) tagsPadre.get(i); tagsHijos.addAll(tdao.getSonTags(name)); arg0.getSession().setAttribute(name, tagsHijos); } } catch (SQLException ex) { Logger.getLogger(Inicializacion.class.getName()).log(Level.SEVERE, null, ex); } } public void sessionDestroyed(HttpSessionEvent arg0) { throw new UnsupportedOperationException("Not supported yet."); } }