- 하나의 서블릿 클래스에서 같은 설정 정보를 공유하기 위한 클래스
[설정 방법]
위치 : web.xml
예제 :
<web-app xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd" version="2.4">
.....
<servlet>
<servlet-name>Tester</servlet-name>
<servlet-class>com.example.Tester</servlet-class>
<init-param>
<param-name>AdminEmail</param-name>
<param-value>admin@gmail.com</param-value>
</init-param>
</servlet>
<servlet-mapping>
<servlet-name>Tester</servlet-name>
<url-pattern>/Tester.do</url-pattern>
</servlet-mapping>
......
</web-app>
[사용방법]
String adminEmail = getServletConfig().getInitParameter("AdminEmail");
{OR}
ServletContext context = getServletConfig();
String adminemail = context.getInitParameter("AdminEmail");
댓글 없음:
댓글 쓰기