초기화 정보 얻기
- init() 메소드에서 서블릿 개체 초기화
- 초기화 정보의 위치
-> web.xml
<servlet>
<servlet-name>~</servlet-name>
<servlet-class>~</servlet-class>
<init-param>
<param-name>name</param-name>
<param-value>value</param-value>
- String getInitParameter(String name)
=================================================================================================================
(InitParameterServlet)
import java.io.IOException;
import java.io.PrintWriter;
import java.util.Enumeration;
import javax.servlet.ServletConfig;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
public class InitParameterServlet extends HttpServlet{
@Override
public void init(ServletConfig config) throws ServletException {
// TODO Auto-generated method stub
super.init(config);
}
@Override
protected void service(HttpServletRequest req, HttpServletResponse res)
throws ServletException, IOException {
// TODO Auto-generated method stub
PrintWriter out = res.getWriter();
out.println("초기 파라미터들....");
Enumeration enumer = getInitParameterNames();
while(enumer.hasMoreElements()){
String name = (String)enumer.nextElement();
out.println(name + " ---> " + getInitParameter(name));
}
}
}
'프로그래밍 정리 > Web' 카테고리의 다른 글
Cookies (0) | 2013.07.13 |
---|---|
Servlet의 요청 처리 메서드 (0) | 2013.07.11 |
Servlet 요청 방식 (0) | 2013.07.11 |
Servlet (0) | 2013.07.11 |