반응형
회원 가입 폼에서 입력받은 정보를 자바빈에 저장하고 조회하는 프로그램
<%@ 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">
<title>회원의 정보 입력 폼</title>
</head>
<body>
<h2>회원의 정보 입력 폼</h2>
<form method="post" action="03_addMember.jsp">
<table>
<tr>
<td> 이름 </td>
<td> <input type="text" name="name" size="20"></td>
</tr>
<tr>
<td> 아이디 </td>
<td> <input type="text" name="userid" size="20"></td>
</tr>
<tr>
<td> 별명 </td>
<td> <input type="text" name="nickname" size="20"></td>
</tr>
<tr>
<td> 비밀번호 </td>
<td> <input type="password" name="pwd" size="20"></td>
</tr>
<tr>
<td> 이메일 </td>
<td> <input type="text" name="email" size="20"></td>
</tr>
<tr>
<td> 전화번호 </td>
<td> <input type="text" name="phone" size="11"></td>
</tr>
<tr>
<td><input type="submit" value="전송"> </td>
<td><input type="reset" value="취소"> </td>
</tr>
</table>
</form>
</body>
</html>
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<%
request.setCharacterEncoding("UTF-8");
%>
<jsp:useBean id="member" class="javabeanspack.JavaBeansClass"/>
<jsp:setProperty name="member" property="*"/>
<!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">
<title>Insert title here</title>
</head>
<body>
<h2>입력 완료된 회원 정보</h2>
<table>
<tr>
<td> 이름 </td>
<td><jsp:getProperty name="member" property="name"/></td>
</tr>
<tr>
<td> 아이디 </td>
<td><jsp:getProperty name="member" property="userid"/></td>
</tr>
<tr>
<td> 별명 </td>
<td><jsp:getProperty name="member" property="nickname"/></td>
</tr>
<tr>
<td> 비밀번호</td>
<td><jsp:getProperty name="member" property="pwd"/></td>
</tr>
<tr>
<td> 이메일 </td>
<td><jsp:getProperty name="member" property="email"/></td>
</tr>
<tr>
<td> 전화번호</td>
<td><jsp:getProperty name="member" property="phone"/></td>
</tr>
</table>
</body>
</html>
<%
request.setCharacterEncoding("UTF-8");
%>
-> 한글 깨짐 방지
<jsp:useBean id="member" class="javabeanspack.JavaBeansClass"/>
-> member 객체 생성
<jsp:setProperty name="member" property="*"/>
-> 매개변수 값을 얻어와서 member 객체의 프로퍼티값으로 저장
반응형
'Application > JSP Server' 카테고리의 다른 글
[JSP 실습] 7-1. 이벤트 등록 화면 구현하기 (0) | 2021.04.15 |
---|---|
[JSP] 7. JSP와 데이터베이스 (0) | 2021.04.15 |
[JSP] 6-2. 자바빈으로 프로퍼티 값 얻기와 변경하기 (0) | 2021.04.08 |
[JSP] 6-1. 자바빈 객체 생성하기 (0) | 2021.04.08 |
[JSP] 6. 자바빈 (0) | 2021.04.08 |