Test2.java
==================================
package a.b;
import java.io.IOException;
import java.io.PrintWriter;
import javax.servlet.ServletConfig;
import javax.servlet.ServletContext;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
/**
* Servlet implementation class Test2
*/
public class Test2 extends HttpServlet {
private static final long serialVersionUID = 1L;
/**
* Default constructor.
*/
public Test2() {
// TODO Auto-generated constructor stub
}
/**
* @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
*/
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
// TODO Auto-generated method stub
}
/**
* @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
*/
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
response.setContentType("text/html; charset=EUC-KR");
ServletContext application=this.getServletContext();
ServletConfig config=this.getServletConfig();
PrintWriter out=response.getWriter();
out.println(application.getInitParameter("xxx"));
out.println(config.getInitParameter("zzz"));
}
}
web.xml
===========================================
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" id="WebApp_ID" version="2.5">
<display-name>servlet_0305</display-name>
<welcome-file-list>
<welcome-file>index.html</welcome-file>
<welcome-file>index.htm</welcome-file>
<welcome-file>index.jsp</welcome-file>
<welcome-file>default.html</welcome-file>
<welcome-file>default.htm</welcome-file>
<welcome-file>default.jsp</welcome-file>
</welcome-file-list>
<servlet>
<description></description>
<display-name>Test2</display-name>
<servlet-name>Test2</servlet-name>
<servlet-class>a.b.Test2</servlet-class>
<init-param>
<param-name>
zzz
</param-name>
<param-value>
yyy
</param-value>
</init-param>
</servlet>
<servlet-mapping>
<servlet-name>Test2</servlet-name>
<url-pattern>/Test2</url-pattern>
</servlet-mapping>
<context-param>
<param-name>xxx</param-name>
<param-value>www</param-value>
</context-param>
</web-app>
'개발하자 > JSP&Servlet' 카테고리의 다른 글
서블릿에서 db아이디목록 불러와서 b.jsp에 뿌리기 (0) | 2015.03.05 |
---|---|
서블릿에서의 화면이동하기 (0) | 2015.03.05 |
서블릿 한글값 넘기기 (0) | 2015.03.05 |
Servlet doget호출하여 doget에서 dopost호출 (0) | 2015.03.05 |
emp테이블의 ename을 출력하고 클릭하면 상세내용나오게 하기 (0) | 2015.03.01 |