Happy Codings - Programming Code Examples
Html Css Web Design Sample Codes CPlusPlus Programming Sample Codes JavaScript Programming Sample Codes C Programming Sample Codes CSharp Programming Sample Codes Java Programming Sample Codes Php Programming Sample Codes Visual Basic Programming Sample Codes


Java Programming Code Examples

Java > Servlets Code Examples

Servlet context event notifications

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43
Servlet context event notifications package com.ack.web.servlet; import javax.servlet.ServletContextAttributeEvent; import javax.servlet.ServletContextAttributeListener; import javax.servlet.ServletContextEvent; import javax.servlet.ServletContextListener; /** * Get application events for when the web application, that is * the servlet context, is initialised and destroyed. Also, when * attributed are added, removed and replaced within the servlet * context. * <listener> <listener-class>com.ack.web.servlet.ServletContextEventNotifications</listener-class> </listener> */ public class ServletContextEventNotifications implements ServletContextListener, ServletContextAttributeListener { public void contextInitialized( ServletContextEvent evt ) { System.out.println( "initialised -> " + evt.getServletContext() ); } public void contextDestroyed( ServletContextEvent evt ) { System.out.println( "destroyed -> " + evt.getServletContext() ); } public void attributeAdded( ServletContextAttributeEvent evt ) { System.out.println( "attributed added: " + evt ); } public void attributeRemoved( ServletContextAttributeEvent evt ) { System.out.println( "attributed removed: " + evt ); } public void attributeReplaced( ServletContextAttributeEvent evt ) { System.out.println( "attributed replaced: " + evt ); } }