■ ServletContextListener Test
( http://www.mkyong.com/servlet/what-is-listener-servletcontextlistener-example/ )
1. ServletContextListener Example
1) Create a class and implement the ServletContextListener interface
package com.mkyong;
import javax.servlet.ServletContextEvent;
import javax.servlet.ServletContextListener;
public class AppServletContextListener implements ServletContextListener{
@Override
public void contextDestroyed(ServletContextEvent arg0) {
System.out.println("ServletContextListener destroyed");
}
@Override
public void contextInitialized(ServletContextEvent arg0) {
System.out.println("ServletContextListener started");
}
}
2) Put it in deployment descriptor ( web.xml )
<web-app ...>
<listener>
<listener-class>com.mkyong.AppServletContextListener</listener-class>
</listener>
</web-app>
( http://www.mkyong.com/servlet/what-is-listener-servletcontextlistener-example/ )
1. ServletContextListener Example
1) Create a class and implement the ServletContextListener interface
package com.mkyong;
import javax.servlet.ServletContextEvent;
import javax.servlet.ServletContextListener;
public class AppServletContextListener implements ServletContextListener{
@Override
public void contextDestroyed(ServletContextEvent arg0) {
System.out.println("ServletContextListener destroyed");
}
@Override
public void contextInitialized(ServletContextEvent arg0) {
System.out.println("ServletContextListener started");
}
}
2) Put it in deployment descriptor ( web.xml )
<web-app ...>
<listener>
<listener-class>com.mkyong.AppServletContextListener</listener-class>
</listener>
</web-app>
3) restart tomcat server
'java' 카테고리의 다른 글
[Java] 언어별 no-cache 리스트 (0) | 2014.05.07 |
---|---|
[Java] 카멜, 파스칼 표기법 ( Camel, Pascal ) (0) | 2014.05.07 |
[Java] 동적 서블릿 맵핑[Dynamic Servlet Mapping] (0) | 2014.05.07 |
[Java] Spring 동작 순서 (0) | 2014.05.07 |
Spring 구동 원리 (0) | 2014.05.07 |
댓글