WebApp ServletContext 초기화 및 소멸

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


번호 제목 글쓴이 날짜 조회 수
191 Servlet의 각종 Listener 사용방법 및 샘플 황제낙엽 2010.10.26 83
» ServletContext 초기화 및 소멸 황제낙엽 2010.10.26 75
189 java.lang.Object 객체 소멸 - finalize() 황제낙엽 2010.10.08 35
188 Array 또는 List 의 Sort (목록 소트) 황제낙엽 2010.09.14 27
187 Class.getResource() 와 ClassLoader.getResource()의 차이점 황제낙엽 2010.06.25 20
186 Designing RMI Applications 황제낙엽 2010.06.24 505
185 Java Node to String Conversion 황제낙엽 2010.06.10 54
184 Java SE 6 Mustang 5장 스크립팅 기능 (번역중) 황제낙엽 2010.06.10 21
183 Java6 에서 지원하는 Scripting (번역중) 황제낙엽 2010.05.28 216
182 RMI 시작하기(2) file 황제낙엽 2010.05.27 12
181 RMI 시작하기(1) file 황제낙엽 2010.05.27 67
180 Java Remote Method Invocation (Java RMI) 황제낙엽 2010.05.27 51
179 javax.script API 관련 스크랩 (ScriptEngine, ScriptEngineManager) 황제낙엽 2010.05.25 112
178 java.util.Properties 파일 사용 예제 file 황제낙엽 2010.04.06 68
177 10진수 <-> 16진수(Hex) 변환 file 황제낙엽 2010.03.29 1225
176 ServletConfig 이용하기 황제낙엽 2010.03.15 22
175 16비트 CRC 체크용 클래스 (사용자 클래스) 황제낙엽 2010.03.14 406
174 파일을 읽어서 CRC 값을 연산하는 메서드 (java.util.zip.CRC32) 황제낙엽 2010.03.14 137
173 byte배열에 대한 CRC 를 계산하는 메서드 (java.util.zip.CRC32) 황제낙엽 2010.03.14 2166
172 java의 List와 반복문(loop), 그리고 변수 선언 위치에 대해서 황제낙엽 2010.02.17 182