0904(ServletContext Test)

import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;

public class Context1 extends HttpServlet{
     private ServletContext cont;
     //ServletConfig conf는 이미있는 메모리를 가져가 쓰는것.
public void init(ServletConfig conf)throws ServletException{
  super.init(conf);
  cont=conf.getServletContext();//init()에서 초기화를 시키면 service()에서 가져가 쓸수있다.
  cont.setAttribute("name",new String("Park su keun"));
  cont.setAttribute("i",this);//자신의 객체를 공유
  System.out.println("init()");
 }

public void service(HttpServletRequest req,HttpServletResponse res){
  System.out.println("Context1's service()");
 }

 //Life Cycle과는 관계없는 내부에서 필요한 method 정의
public String message(){
  return "hello";
 }

public void destroy(){
  System.out.println("destroy()");
 }
}

이 글과 관련있는 글을 자동검색한 결과입니다 [?]

이 글과 관련있는 글을 자동검색한 결과입니다 [?]

by 후아 | 2007/09/05 00:44 | SERVLET | 트랙백 | 덧글(0)

트랙백 주소 : http://ahdbsdlf.egloos.com/tb/691158
☞ 내 이글루에 이 글과 관련된 글 쓰기 (트랙백 보내기) [도움말]

:         :

:

비공개 덧글

<< 이전 페이지다음 페이지 >>