WebApp ServletContext 초기화 및 소멸

황제낙엽 2010.10.26 19:58 조회 수 : 636 추천:57

sitelink1  
sitelink2  
sitelink3  
sitelink4  
sitelink5  
sitelink6  

웹서버의 최초 구동시와 정지시에 수행하게 되는 클래스가 있다

ServletContextListener.java

이를 이용하여 서버 시작시나 정지시에 수행해야 할 작업을 정의할 수 있다

 

package com.tobesoft.xplatform.console.services;  
 
import javax.servlet.ServletContext;  
import javax.servlet.ServletContextEvent;  
import javax.servlet.ServletContextListener;  
 
/** 
 * <p> 
 * 프로젝트 관리메뉴. 
 *  
 * @author Lee KiEun 
 */ 
public class CompileListener implements ServletContextListener {  
 
    private ServletContext context = null;  
 
    /* 
     * This method is invoked when the Web Application has been removed and is 
     * no longer able to accept requests 
     */ 
 
    public void contextDestroyed(ServletContextEvent event) {  
          
        // Output a simple message to the server's console  
        System.out.println("The Simple Web App. Has Been Removed");  
        this.context = null;  
 
    }  
 
    // This method is invoked when the Web Application  
    // is ready to service requests  
 
    public void contextInitialized(ServletContextEvent event) {  
          
        this.context = event.getServletContext();  
 
        // Output a simple message to the server's console  
        System.out.println("The Simple Web App. Is Ready");  
 
    }  
}  



<listener> 
    <listener-class> 
        com.tobesoft.xplatform.console.services.CompileListener  
    </listener-class> 
</listener> 


번호 제목 글쓴이 날짜 조회 수
206 volatile 에 대한 단상(斷想) 황제낙엽 2011.06.22 592
205 Object element 의 onerror 이벤트 황제낙엽 2011.04.21 729
204 Java 2D Graphics - Reference link 황제낙엽 2011.04.11 642
203 deployJava.js를 이용한 JRE 자동설치 및 Applet 디플로이 file 황제낙엽 2011.04.04 1292
202 Applet 의 모든것 황제낙엽 2011.04.01 983
201 Java Applets in HTML5 황제낙엽 2010.12.13 1042
200 (Multiple Browser Supported) Java applet using XHTML 'object' tag 황제낙엽 2010.12.13 805
199 <Applet> 과 <Object> 종합 황제낙엽 2010.12.07 730
198 codebase 를 통한 autodownload 내용 황제낙엽 2010.12.07 1419
197 오브젝트(object), 이미지와 애플렛(applet) 황제낙엽 2010.12.07 746
196 [Applet] Java Plug-in 1.4.2 Developer Guide 황제낙엽 2010.12.07 821
195 [Applet] Java Plugin 가이드 (OBJECT/EMBED 태그에 의한 인트라넷) 황제낙엽 2010.11.06 790
194 [Applet] Java Plugin 가이드 (HTML 컨버터를 사용한 Java Plug-in 용 Applet 태그의 변환) 황제낙엽 2010.11.06 670
193 [Applet] Java Plugin 가이드 (applet,object, 및 embed 태그의 사용) 황제낙엽 2010.11.06 710
192 [Applet] Java Plugin 가이드 (Java Plug-in 란. 지원 내용에 대해) 황제낙엽 2010.11.06 759
191 Escape special characters 황제낙엽 2010.10.28 649
190 Servlet의 각종 Listener 사용방법 및 샘플 황제낙엽 2010.10.26 617
» ServletContext 초기화 및 소멸 황제낙엽 2010.10.26 636
188 java.lang.Object 객체 소멸 - finalize() 황제낙엽 2010.10.08 781
187 Array 또는 List 의 Sort (목록 소트) 황제낙엽 2010.09.14 710