자바빈을 이용하여 회원가입 페이지를 만들어보자
먼저 자바빈을 설정한다.
package com.human.javabeans;
public class MemberBean {
private String name;
private String userid;
private String nickname;
private String pwd;
private String email;
private String phone;
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getUserid() {
return userid;
}
public void setUserid(String userid) {
this.userid = userid;
}
public String getNickname() {
return nickname;
}
public void setNickname(String nickname) {
this.nickname = nickname;
}
public String getPwd() {
return pwd;
}
public void setPwd(String pwd) {
this.pwd = pwd;
}
public String getEmail() {
return email;
}
public void setEmail(String email) {
this.email = email;
}
public String getPhone() {
return phone;
}
public void setPhone(String phone) {
this.phone = phone;
}
}
그리고 HTML로 회원가입 폼을 만든다.
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
</head>
<body>
<form method="POST" action="02_addMember.jsp">
<table>
<thead>
<h2>회원의 정보 입력 폼</h2>
</thead>
<tr>
<td>이름</td>
<td><input type="text" name="name"></td>
</tr>
<tr>
<td>아이디</td>
<td><input type="text" name="userId"></td>
</tr>
<tr>
<td>별명</td>
<td><input type="text" name="nickName"></td>
</tr>
<tr>
<td>비밀번호</td>
<td><input type="password" name="pwd"></td>
</tr>
<tr>
<td>이메일</td>
<td><input type="email" name="mail"></td>
</tr>
<tr>
<td>전화번호</td>
<td><input type="text" name="phone"></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"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
</head>
<body>
<%request.setCharacterEncoding("UTF-8"); %>
<jsp:useBean class="com.human.javabeans.MemberBean" id="member" scope="page"/>
<jsp:setProperty property="name" name="member" value='<%=request.getParameter("name") %>'/>
<jsp:setProperty property="userid" name="member" value='<%=request.getParameter("userId") %>'/>
<jsp:setProperty property="nickname" name="member" value='<%=request.getParameter("nickName") %>'/>
<jsp:setProperty property="pwd" name="member" value='<%=request.getParameter("pwd") %>'/>
<jsp:setProperty property="email" name="member" value='<%=request.getParameter("mail") %>'/>
<jsp:setProperty property="phone" name="member" value='<%=request.getParameter("phone") %>'/>
<table>
<thead>
<h2>입력 완료된 회원 정보</h2>
</thead>
<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>
728x90
반응형
'JSP, Servlet > JSP, Servlet 기초' 카테고리의 다른 글
[JSP/Servlet] 자바빈을 이용하여 상품정보 등록하기 (0) | 2020.08.12 |
---|---|
[JSP/Servlet] 자바빈을 이용하여 게시판 만들기 (0) | 2020.08.12 |
[JSP/Servlet] 자바빈 getProperty, setProperty (0) | 2020.08.12 |
[JSP/Servlet] 자바빈 useBean (0) | 2020.08.12 |
[JSP/Servlet] 자바빈 기초(javabean basic) (0) | 2020.08.12 |