Java/Servlets/Listener — различия между версиями
Admin (обсуждение | вклад) м (1 версия) |
|
(нет различий)
|
Текущая версия на 09:11, 1 июня 2010
Содержание
Application EventListeners
Servlets Application Listener
<source lang="java">
import javax.servlet.*; import javax.servlet.http.*; public class AppListener extends HttpServlet implements ServletContextListener {
private ServletContext context = null; public void contextInitialized(ServletContextEvent event) { context = event.getServletContext(); context.setAttribute("Counter", new Integer(0)); } public void contextDestroyed(ServletContextEvent event) { context = event.getServletContext(); context.log ((String)context.getAttribute("Counter")); context.removeAttribute("Counter"); }
}
</source>