Skip to content

Instantly share code, notes, and snippets.

@sjyun
Created May 7, 2014 07:38
Show Gist options
  • Select an option

  • Save sjyun/9a13c8bb7223d5d3b368 to your computer and use it in GitHub Desktop.

Select an option

Save sjyun/9a13c8bb7223d5d3b368 to your computer and use it in GitHub Desktop.
초기화파라미터 전달
package test0911;
import java.io.IOException;
import javax.servlet.ServletConfig;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebInitParam;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
@WebServlet(name = "initParamServlet", urlPatterns = "{/init}",
initParams = { @WebInitParam(name = "siteName", value = "burning.com") })
public class InitParamServlet extends HttpServlet {
private static final long serialVersionUID = 1L;
private String myParam = "";
public void init(ServletConfig servletConfig) throws ServletException {
this.myParam = servletConfig.getInitParameter("siteName");
System.out.println("사이트명은 " + myParam + "입니다.");
}
public void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
System.out.println("doGet메소드 호출");
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment