'javax.servlet.ServletContext'에 해당되는 글 1건

  1. 2012.04.23 2012-4-23 javax.servlet.ServletContext

* javax.servlet.ServletContext(어플리케이션에 대한 업무를 처리할 정보를 가지고 있다.)


   - Web Application이 자체 또는 일하는데 필요한 정보를 가지고 있는 객체
      - Web Component는 Web Application과 관련된 정보를 조회하거나 업무를 처리할 때 ServletContext type객체를 이용
      - Web Application이 시작 할때 Web Container에 의해 생성 된다.
      - Servlet의 getServletContext()를 통해 조회
         - ServletContext ctx = getServletContext();
      - Web Application 당 하나가 생성됨

* ServletContext를 이용한 초기 파라미터 처리


1. web.xml 에 초기 파라미터 설정
<web-app>
   <context-param>
      <param-name>초기파라미터 이름</param-name>
      <param-value>초기파라미터 값</param-value>
   </context-param>
   - 초기 파라미터가 여러개인 경우<context-param>반복
2. 코드상에서 조회
   ServletContext객체.getInitParameter(String paramName) : String paramValue

 

Posted by 조은성
,