[JSP/Servlet] 자바빈으로 회원가입 폼 만들기 예제

register.html

<!DOCTYPE html>

<html>

<head>

<meta charset="EUC-KR">

<title>Insert title here</title>

</head>

<body>

<h1>회원 가입</h1>

<form action="register_proc.jsp" method="post">

아이디 : <input type="text" name="mem_id"/><br><br>

패스워드 : <input type="password" name="mem_pw"/><br><br>

이름 : <input type="text" name="mem_name"/><br><br>

이메일 : <input type="text" name="mem_email"/><br><br>

전화번호 : <input type="text" name="mem_tel"/><br><br>

주소 : <input type="text" name="mem_addr"/><br><br>

<input type="submit" value="전송"/>

</form>

</body>

</html>


register_proc.jsp

<%@ page language="java" contentType="text/html; charset=EUC-KR"%>

<!DOCTYPE html>

<html>

<head>

<title>Insert title here</title>

</head>

<body>

<%request.setCharacterEncoding("EUC-KR"); %>

<jsp:useBean id="mem" class="mybean.MemberDto"/>

<jsp:setProperty property="*" name="mem"/>

<%

/*

String id = request.getParameter("mem_id");

String pw = request.getParameter("mem_pw");

String name = request.getParameter("mem_name");

String email = request.getParameter("mem_email");

String tel = request.getParameter("mem_tel");

String addr = request.getParameter("mem_addr");

*/

%>

<h2>당신이 입력한 내용입니다.</h2>

아이디 : <jsp:getProperty property="mem_id" name="mem"/><br>

패스워드 : <jsp:getProperty property="mem_pw" name="mem"/><br>

이름 : <jsp:getProperty property="mem_name" name="mem"/><br>

이메일 : <jsp:getProperty property="mem_email" name="mem"/><br>

전화번호 : <jsp:getProperty property="mem_tel" name="mem"/><br>

주소 : <jsp:getProperty property="mem_addr" name="mem"/><br>

</body>

</html>


MemberDto.java

package mybean;


public class MemberDto {

private String mem_id;

private String mem_pw;

private String mem_name;

private String mem_email;

private String mem_tel;

private String mem_addr;

public String getMem_id() {

return mem_id;

}

public void setMem_id(String mem_id) {

this.mem_id = mem_id;

}

public String getMem_pw() {

return mem_pw;

}

public void setMem_pw(String mem_pw) {

this.mem_pw = mem_pw;

}

public String getMem_name() {

return mem_name;

}

public void setMem_name(String mem_name) {

this.mem_name = mem_name;

}

public String getMem_email() {

return mem_email;

}

public void setMem_email(String mem_email) {

this.mem_email = mem_email;

}

public String getMem_tel() {

return mem_tel;

}

public void setMem_tel(String mem_tel) {

this.mem_tel = mem_tel;

}

public String getMem_addr() {

return mem_addr;

}

public void setMem_addr(String mem_addr) {

this.mem_addr = mem_addr;

}

}


결과



댓글

Designed by JB FACTORY