Archive

JSP - 자바빈즈를 활용한 회원가입 구현

|

JSP - 자바빈즈를 활용한 회원가입 구현


자바빈즈를 활용하여 간단한 회원가입 어플리케이션을 구현해보자

<!-- /actiontag/register.jsp -->
<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Customer 가입페이지</title>
</head>
<body>
	<form method="post" action="add.jsp">
		<table border="1" width="300">
			<tr>
				<td width="100">이름</td>
				<td width="200"><input type="text" name="name" size="25" /></td>
			</tr>
			<tr>
				<td width="100">이메일</td>
				<td width="200"><input type="text" name="email" size="25" /></td>
			</tr>
			<tr>
				<td width="100">전번</td>
				<td width="200"><input type="text" name="phone" size="25" /></td>
			</tr>
			<tr>
				<td colspan="2" align="center">
					<input type="submit" value="가입" />				
				</td>
			</tr>
		</table>
	</form>
</body>
</html>
<!-- /actiontag/add.jsp -->
<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%--<%@ page import="actiontag.Customer" %> --%>
<% request.setCharacterEncoding("utf-8"); %>
<jsp:useBean id="customer" class="actiontag.Customer" scope="page" />
<jsp:setProperty name="customer" property="*" />
<!DOCTYPE html>
<html>
<head>
<meta charset="EUC-KR">
<title>Customer 가입정보</title>
</head>
<body>
	<ul>
		<li>
			이름 : <jsp:getProperty name="customer" property="name" />
		</li>
		<li>
			이메일 : <jsp:getProperty name="customer" property="email" />
		</li>
		<li>
			전화 : <jsp:getProperty name="customer" property="phone" />
		</li>
	</ul>
</body>
</html>
// /src/actiontag/Customer.java
package actiontag;

public class Customer {
	private String name;
	private String email;
	private String phone;
	
	public String getName() {
		return name;
	}
	public void setName(String name) {
		this.name = name;
	}
	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;
	}
}
  • 실행화면

실행1

실행2



참고 자료


KG 아이티뱅크 강의 자료

처음해보는 JSP&Servlet 웹 프로그래밍