Jsp_Html
[Jsp] ServletConfig, ServletContext
Sort
2010. 6. 17. 11:05
servletContext - 다른 서블릿에서도 공유되는 내용.
servletConfig - 그 서블릿에서만 사용되는 내용
servletConfig 예제
<servlet>
<servlet-name>Hello</servlet-name>
<servlet-class>aaa.Aservlet</servlet-class>
<init-param>
<param-name>hello</param-name>
<param-value>Good</param-value>
</init-param>
</servlet>
사용시 - String a=getInitParameter("hello");
servletContext 예제
<context-param>
<param-name>location</param-name>
<param-value>/WEB-INF/A.txt</param-value>
</context-param>
사용시 -
ServletContext context = getServletContext()
String location = context.getInitParameter("location");
setAttrubute(), getAttribute()