보내는 파일 : form.jsp
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<!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=UTF-8">
<script>
function ButtonSubmit(form){
form.method = "post"
form.action = "./result.jsp"; // 목적지
form.submit(); // 제출
}
</script>
</head>
<body>
<form name="theForm">
<table border="1">
<tr>
<th>이름</th>
<td><input type="text" id="name" name="name"></td>
</tr>
<th>번호</th>
<td><input type="text" id="ph_number" name="ph_number"></td>
<tr>
<th>주소</th>
<td><input type="text" id="address" name="address"></td>
</table>
<br>
<input type="button" value="제출" onclick="javascript:ButtonSubmit(document.theForm)"><!--"document.form" == " {현재 문서}.{name 값이 theForm인 }"-->
</form>
</body>
</html>
받는 파일 : result.jsp
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<%
request.setCharacterEncoding("utf-8"); //파라미터 값에 한글이 들어가는 경우
String name = request.getParameter("name");
String ph_number = request.getParameter("ph_number");
String address = request.getParameter("address");
%>
<!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=UTF-8">
</head>
<body>
<table border="1">
<tr>
<th>[확인] 이름</th>
<td><%=name%></td>
</tr>
<th>[확인] 번호</th>
<td><%=ph_number%></td>
<tr>
<th>[확인] 주소</th>
<td><%=address%></td>
</tr>
</table>
</body>
</html>
입력 후 "제출" 클릭
결과
'시작' 카테고리의 다른 글
[Date Format][년, 월, 일, 시, 분, 초] 기호 표기 방법 (0) | 2021.11.22 |
---|---|
[HTML] 동적 셀렉트 박스, 콤보 박스, 드롭 다운 생성 (0) | 2021.11.19 |
[JSP][Form Tag][Ajax][POST] 데이터 전송 및 받기 (0) | 2021.10.28 |
[JSP][Form Tag][jQuery] 데이터 전송 및 받기 (0) | 2021.10.28 |
[JSP][Form Tag][Action] 데이터 전송 및 받기 (0) | 2021.10.27 |