JAVA야

[복사되는블로그 꼬마갱이]Tomcat 시작시 Class시작

administrators 2009. 8. 6. 16:59

1. /WEB-INF/web.xml

 

    <web-app>

.

.

<!-- web-app 태그 사이에 만든다 -->

  <servlet>
    <servlet-name>com.test.StartJava</servlet-name>
    <servlet-class>com.test.StartJava</servlet-class>
    <load-on-startup>1</load-on-startup>
  </servlet>

 

  <servlet-mapping>
    <servlet-name>com.test.StartJava</servlet-name>
    <url-pattern>/StartJava</url-pattern>
  </servlet-mapping>

.

.

    </web-app>

* load-on-startup 태그 (자세한건 더 검색해보세요.)

음 : 서블릿호출시 실행

양: (또는 0) 톰켓시작시

 

2. StartJava.class

package com.test;

 

import! java.io.IOException;

import! javax.servlet.ServletConfig;
import! javax.servlet.http.HttpServlet;
import! javax.servlet.http.HttpServletRequest;
import! javax.servlet.http.HttpServletResponse;

 

public class StartJava extends HttpServlet{
 public void init(ServletConfig config) {
        System.out.println("#############################################");

        System.out.println("This is StartJava.class  >>>  init");
        System.out.println("#############################################");
    }

    public void service(
      HttpServletRequest request, HttpServletResponse response)
            throws IOException, ClassCastException{
    }
}

 

 

'JAVA야' 카테고리의 다른 글

LinkedHashMap 순서가 있는 hash  (0) 2009.12.07
replace(1.4이전에서 구현)  (0) 2009.12.07
리플렉션  (0) 2009.12.07
SingletonTest  (0) 2009.12.07
XML을 파싱해보자~  (0) 2009.09.02