abc.java
============================
package p1;
import java.io.IOException;
import java.io.PrintWriter;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
/**
* Servlet implementation class abc
*/
@WebServlet("/abc")
public class abc extends HttpServlet {
private static final long serialVersionUID = 1L;
/**
* @see HttpServlet#HttpServlet()
*/
public abc() {
super();
// TODO Auto-generated constructor stub
}
/**
* @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
*/
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
this.doPost(request, response);
}
/**
* @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
*/
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
request.setCharacterEncoding("euc-kr");
response.setContentType("text/html; charset=EUC-KR");
PrintWriter out=response.getWriter();
out.println(request.getParameter("v1")+"<br>");
out.println(request.getParameter("v2"));
}
}
a.jsp
=================================
<%@ page language="java" contentType="text/html; charset=EUC-KR"
pageEncoding="EUC-KR"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=EUC-KR">
<title>Insert title here</title>
</head>
<body>
<form action="<%=request.getContextPath()%>/abc" method="post">
<input type="text" name=v1>
<input type="text" name=v2>
<input type="submit" value="전송">
</form>
</body>
</html>
'개발하자 > JSP&Servlet' 카테고리의 다른 글
서블릿에서의 화면이동하기 (0) | 2015.03.05 |
---|---|
ServletContext,ServletConfig (0) | 2015.03.05 |
Servlet doget호출하여 doget에서 dopost호출 (0) | 2015.03.05 |
emp테이블의 ename을 출력하고 클릭하면 상세내용나오게 하기 (0) | 2015.03.01 |
한폼에 submit버튼 두개일 때 이동페이지 설정 (0) | 2015.03.01 |