WebApp ServletContext 초기화 및 소멸

황제낙엽 2010.10.26 19:58 조회 수 : 428 추천: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> 


번호 제목 글쓴이 날짜 조회 수
203 Applet 의 모든것 황제낙엽 2011.04.01 620
202 Java Applets in HTML5 황제낙엽 2010.12.13 728
201 (Multiple Browser Supported) Java applet using XHTML 'object' tag 황제낙엽 2010.12.13 417
200 <Applet> 과 <Object> 종합 황제낙엽 2010.12.07 389
199 codebase 를 통한 autodownload 내용 황제낙엽 2010.12.07 961
198 오브젝트(object), 이미지와 애플렛(applet) 황제낙엽 2010.12.07 394
197 [Applet] Java Plug-in 1.4.2 Developer Guide 황제낙엽 2010.12.07 401
196 [Applet] Java Plugin 가이드 (OBJECT/EMBED 태그에 의한 인트라넷) 황제낙엽 2010.11.06 443
195 [Applet] Java Plugin 가이드 (HTML 컨버터를 사용한 Java Plug-in 용 Applet 태그의 변환) 황제낙엽 2010.11.06 339
194 [Applet] Java Plugin 가이드 (applet,object, 및 embed 태그의 사용) 황제낙엽 2010.11.06 441
193 [Applet] Java Plugin 가이드 (Java Plug-in 란. 지원 내용에 대해) 황제낙엽 2010.11.06 409
192 Escape special characters 황제낙엽 2010.10.28 450
191 Servlet의 각종 Listener 사용방법 및 샘플 황제낙엽 2010.10.26 406
» ServletContext 초기화 및 소멸 황제낙엽 2010.10.26 428
189 java.lang.Object 객체 소멸 - finalize() 황제낙엽 2010.10.08 608
188 Array 또는 List 의 Sort (목록 소트) 황제낙엽 2010.09.14 537
187 Class.getResource() 와 ClassLoader.getResource()의 차이점 황제낙엽 2010.06.25 548
186 Designing RMI Applications 황제낙엽 2010.06.24 2759
185 Java Node to String Conversion 황제낙엽 2010.06.10 393
184 Java SE 6 Mustang 5장 스크립팅 기능 (번역중) 황제낙엽 2010.06.10 477