정보를 보내는 code
<label>아이디</label>
<input type="text" name="id" id="id">
<br>
<label>패스워드</label>
<input type="password" name="pw" id="pw">
<br>
<label>이름</label>
<input type="text" name="name" id="name">
<br>
<label>전화번호</label>
<input type="text" name="phone" id="phone">
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>정보를 보내는 곳</title>
<script src="http://code.jquery.com/jquery-latest.min.js"></script>
</head>
<body>
<form action="jsp0125_register04.jsp" method="post" name="frm">
<label>아이디</label>
<input type="text" name="id" id="id">
<br>
<label>패스워드</label>
<input type="password" name="pw" id="pw">
<br>
<label>이름</label>
<input type="text" name="name" id="name">
<br>
<label>전화번호</label>
<input type="text" name="phone" id="phone">
<br>
<br>
<input type="submit" value="회원가입">
</form>
</body>
</html>
받아오는 방법 1 : useBean
<jsp:useBean id="mdto" class="com.java.www.MemberDto" scope="page"/>
<!--원하는 class의 객체를 하나 만들고 -->
<jsp:setProperty name="mdto" property="*"/>
<!--form으로 받아 온 정보를 위에서 생성한 mdto의 property에
넣는다(setProperty) -->
<!--*은 무슨 뜻일까?
*은 form을 통해서 리퀘스트로 넘어온 모든 데이터들을
각 이름에 해당하는 객체의 인스턴스변수로 한꺼번에 다 지정해준다는 뜻이다.-->
<tr>
<th>아이디</th>
<td><%=mdto.getId() %></td>
</tr>
usebean에서 객체 선언되고 form의 정보를 받아 온 mdto의 getter를 통해
id정보를 받아온다.
<%request.setCharacterEncoding("utf-8"); %>
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<jsp:useBean id="mdto" class="com.java.www.MemberDto" scope="page"/>
<jsp:setProperty name="mdto" property="*"/>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>register</title>
</head>
<body>
<h2>회원가입완료</h2>
<table>
<tr>
<th>아이디</th>
<td><%=mdto.getId() %></td>
</tr>
<tr>
<th>패스워드</th>
<td><%=mdto.getPw() %></td>
</tr>
<tr>
<th>아룸</th>
<td><%=mdto.getName() %></td>
</tr>
<tr>
<th>전화번호</th>
<td><%=mdto.getPhone() %></td>
</tr>
</table>
</body>
</html>
받아오는 방법2: request.getParameter("")
<tr>
<th>아이디</th>
<td><%=request.getParameter("id") %></td>
</tr>
request.getParameter("name값") 로 받아오기
<%request.setCharacterEncoding("utf-8"); %>
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>register</title>
</head>
<body>
<h2>회원가입완료</h2>
<table>
<tr>
<th>아이디</th>
<td><%=request.getParameter("id") %></td>
</tr>
<tr>
<th>패스워드</th>
<td><%=request.getParameter("pw")%></td>
</tr>
<tr>
<th>아룸</th>
<td><%=request.getParameter("name") %></td>
</tr>
<tr>
<th>전화번호</th>
<td><%=request.getParameter("phone")%></td>
</tr>
</table>
</body>
</html>
받아오는 방법3: ${param.} /jstl
<tr>
<th>아이디</th>
<td>${param.id}</td>
</tr>
<!--${param.id} 는 request.getParameter("id") 과 같다.-->
<%request.setCharacterEncoding("utf-8"); %>
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>register</title>
</head>
<body>
<h2>회원가입완료</h2>
<table>
<tr>
<th>아이디</th>
<td>${param.id}</td>
</tr>
<tr>
<th>패스워드</th>
<td>${param.pw}</td>
</tr>
<tr>
<th>아룸</th>
<td>${param.name}</td>
</tr>
<tr>
<th>전화번호</th>
<td>${param.phone}</td>
</tr>
</table>
</body>
</html>
받아오는 방법4: ${mdto.} or ${jsp:getProperty}/jstl
<jsp:useBean id="mdto" class="com.java.www.MemberDto" scope="page"/>
<jsp:setProperty name="mdto" property="*"/>
1번과 같은 방식으로 form 정보를 mdto에 넣음
이후
<tr>
<th>아이디</th>
<td>${mdto.id}</td>
</tr>
선언 된 mdto로 id가져오기
<tr>
<th>아이디</th>
<td><jsp:getProperty property="id" name="mdto"/></td>
</tr>
jsp:getPropery로 가져오기
<%request.setCharacterEncoding("utf-8"); %>
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<jsp:useBean id="mdto" class="com.java.www.MemberDto" scope="page"/>
<jsp:setProperty name="mdto" property="*"/>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>register</title>
</head>
<body>
<h2>회원가입완료</h2>
<table>
<tr>
<th>아이디</th>
<td><jsp:getProperty property="id" name="mdto"/></td>
</tr>
<tr>
<th>패스워드</th>
<td><jsp:getProperty property="pw" name="mdto"/></td>
</tr>
<tr>
<th>아룸</th>
<td><jsp:getProperty property="name" name="mdto"/></td>
</tr>
<tr>
<th>전화번호</th>
<td><jsp:getProperty property="phone" name="mdto"/></td>
</tr>
</table>
<hr>
<table>
<tr>
<th>아이디</th>
<td>${mdto.id}</td>
</tr>
<tr>
<th>패스워드</th>
<td>${mdto.pw}</td>
</tr>
<tr>
<th>아룸</th>
<td>${mdto.name}</td>
</tr>
<tr>
<th>전화번호</th>
<td>${mdto.phone}</td>
</tr>
</table>
</body>
</html>