자바빈 사용 예제

essential·2023년 8월 6일
0

JSP

목록 보기
17/21

JoinBean.java

package join;

public class JoinBean {
	private String id;
	private	String pass;
	private String name;
	private int sex;
	private int age;
	private String email;

	public String getId() {
		return id;
	}
	
	public void setId(String id) {
		this.id=id;
	}
	
	public String getPass() {
		return pass;
	}

	public void setPass(String pass) {
		this.pass = pass;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public int getSex() {
		return sex;
	}

	public void setSex(int sex) {
		this.sex = sex;
	}

	public int getAge() {
		return age;
	}

	public void setAge(int age) {
		this.age = age;
	}

	public String getEmail() {
		return email;
	}

	public void setEmail(String email) {
		this.email = email;
	}
	
}

joinForm.jsp

<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>회원가입 폼</title>
</head>
<body>
<center>
<form action="joinChk.jsp" method="post">
<table border=0>
	<tr>
		<td align=right bgcolor="yellow"><font size=2>아이디 :</font></td>
		<td bgcolor="yellow"><input type="text" name="id"></td>
	</tr>
	<tr>
		<td align=right bgcolor="yellow"><font size=2>비밀번호 :</font></td>
		<td bgcolor="yellow"><input type="password" name="pass"></td>
	</tr>
	<tr>
		<td align=right bgcolor="yellow"><font size=2>성별 :</font></td>
		<td bgcolor="yellow">
			<input type="radio" name="sex" value="1" checked><font size=2></font>
			<input type="radio" name="sex" value="1" checked><font size=2></font>
		</td>
	</tr>
	<tr>
		<td align=right bgcolor="yellow"><font size=2>이름 :</font></td>
		<td bgcolor="yellow"><input type="text" name="name"></td>
	</tr>
	<tr>
		<td align=right bgcolor="yellow"><font size=2>나이 :</font></td>
		<td bgcolor="yellow"><input type="text" name="age"></td>
	</tr>
	<tr>
		<td align=right bgcolor="yellow"><font size=2>이메일주소 :</font></td>
		<td bgcolor="yellow"><input type="text" name="email"></td>
	</tr>
	<tr>
		<td align=center bgcolor="yellow" colspan=2>
		<input type="submit" value="가입">
		<input type="reset" value="다시 작성">
		</td>
	</tr>
</table>
</form>
</center>
</body>
</html>

joinChk.jsp

<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%request.setCharacterEncoding("utf-8"); %>
<jsp:useBean id="join" class="join.JoinBean"/>
<jsp:setProperty name="join" property="*"/>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>회원가입 입력 정보 확인 페이지</title>
</head>
<body>
<center>
<form action="joinChk.jsp" method="post">
<table border=1>
	<tr>
		<td align=right bgcolor="yellow"><font size=2>아이디 :</font></td>
		<td bgcolor="yellow"><jsp:getProperty name="join" property="id"/></td>
	</tr>
	<tr>
		<td align=right bgcolor="yellow"><font size=2>비밀번호 :</font></td>
		<td bgcolor="yellow"><jsp:getProperty name="join" property="pass"/></td>
	</tr>
	<tr>
		<td align=right bgcolor="yellow"><font size=2>성별 :</font></td>
		<td bgcolor="yellow"><jsp:getProperty name="join" property="sex"/>
		</td>
	</tr>
	<tr>
		<td align=right bgcolor="yellow"><font size=2>나이 :</font></td>
		<td bgcolor="yellow"><jsp:getProperty name="join" property="age"/></td>
	</tr>
	<tr>
		<td align=right bgcolor="yellow"><font size=2>이메일주소 :</font></td>
		<td bgcolor="yellow"><jsp:getProperty name="join" property="email"/></td>
	</tr>
</table>
</form>
</center>
</body>
</html>

joinForm.jsp 실행 시 화면

가입 시 화면

profile
essential

0개의 댓글