회원가입 양식 폼에서 입력 받은 값  beans 이용해 저장하고 

Property 이용해 가져오기

 

 

[join.html]

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">



<html xmlns="http://www.w3.org/1999/xhtml">



<head>



<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />



<title>무제 문서</title>



<style>



table td, th{ border-bottom:1px solid;border-bottom-color:#999;}



table tr {height:35px;}



</style>



<script src = "script.js">



</script>



</head>



 



<body>



<center>



     <form  name = "join" action="check.jsp" method="post">



         <table width="60%">



                <tr bgcolor="#CCFFFF">



                 <th colspan="2">회원 기본 정보</th>



                </tr>



                <tr>



                 <td>아이디 : </td>



                    <td><input type="text" maxlength="12" name = "id" id="id" min="4" size="12" />  4~12자의 영문 대소문자와 숫자로만 입력</td>



                </tr>



                 <tr>



                 <td>비밀번호 : </td>

s

                    <td><input type="password" maxlength="12" id="password" name ="password" min="4" size="12" />  4~12자의 영문 대소문자와 숫자로만 입력</td>



                </tr>



                <tr>



                 <td>비밀번호 확인 : </td>



                    <td><input type="password" maxlength="12" id="checkpw" name="checkpw" min="4" size="12" /></td>



                </tr>



                <tr>



                 <td>메일 주소 : </td>



                    <td><input type="email" id="email" name="email" size="20" />  예) id@domain.com</td>



                </tr>



                <tr>



                 <td>이름 : </td>



                    <td><input type="text" id="name" name="name" size="25" /></td>



                </tr>



                 <tr bgcolor="#CCFFFF">



                 <th colspan="2">개인 신상 정보</th>



                </tr>



                 <tr>



                 <td>주민등록번호 : </td>



                    <td><input type="text" id= "jumin" name="jumin" maxlength="13" size="15" onkeypress="checkJumin()" /> 예)1234561234567</td>



                </tr>



                 <tr>



                 <td>생일 : </td>



                    <td>



                        <input type="text" id="year" name="year" size = "4"> 년



<select name="getBDayMonth"   size="1">

   <option value=1>1</option>

   <option value=2>2</option>

   <option value=3>3</option>

   <option value=4>4</option>

   <option value=5>5</option>

   <option value=6>6</option>

   <option value=7>7</option>

   <option value=8>8</option>

   <option value=9>9</option>

   <option value=10>10</option>

   <option value=11>11</option>

   <option value=12>12</option>

</select>월

<select name="getBDayDay" id="getBDayDay" size="1">

   <option value=1 >1</option>

   <option value=2>2</option>

   <option value=3>3</option>

   <option value=4>4</option>

   <option value=5>5</option>

   <option value=6>6</option>

   <option value=7>7</option>

   <option value=8>8</option>

   <option value=9>9</option>

   <option value=10>10</option>

   <option value=11>11</option>

   <option value=12>12</option>

   <option value=13>13</option>

   <option value=14>14</option>

   <option value=15>15</option>

   <option value=16>16</option>

   <option value=17>17</option>

   <option value=18>18</option>

   <option value=19>19</option>

   <option value=20>20</option>

   <option value=21>21</option>

   <option value=22>22</option>

   <option value=23>23</option>

   <option value=24>24</option>

   <option value=25>25</option>

   <option value=26>26</option>

   <option value=27>27</option>

   <option value=28>28</option>

   <option value=29>29</option>

   <option value=30>30</option>

   <option value=31>31</option>

   </select>일

   </td>

  </tr>



                    </td>



                </tr>



                <tr>



                 <td>관심분야 확인 : </td>



                    <td><input type="checkbox" name="hobby" value="computer"/>컴퓨터



                     <input type="checkbox" name="hobby" value="internet"/>인터넷



                        <input type="checkbox" name="hobby" value="travel"/>여행



                        <input type="checkbox" name="hobby" value="movie"/>영화감상



                        <input type="checkbox" name="hobby" value="music"/>음악감상



                    </td>



                </tr>



                 <tr>



                 <td>자기소개 : </td>



                    <td><textarea id = "introduce" name="introduce" cols="50" rows="5"></textarea>



                    </td>



                </tr>



            </table>



            <br /><br />



            <input type="submit" value="회원 가입"/>

            <input type="reset" value="초기화" />



         </form>



    </center>



</body>



</html>

 

 

[JoinBean.java]

package Day5;



public class JoinBean {

private String id;

private String password;

private String email;

private String name;

private String jumin;

private int year;

private int getBDayMonth;

private int getBDayDay;

private String[] hobby;

private String hobbylist;

private String introduce;



public String getId() {

return id;

}

public void setId(String id) {

this.id = id;

}

public String getPassword() {

return password;

}

public void setPassword(String password) {

this.password = password;

}

public String getEmail() {

return email;

}

public void setEmail(String email) {

this.email = email;

}

public String getName() {

return name;

}

public void setName(String name) {

this.name = name;

}

public String getJumin() {

return jumin;

}

public void setJumin(String jumin) {

this.jumin = jumin;

}

public int getYear() {

return year;

}

public void setYear(int year) {

this.year = year;

}

public int getGetBDayMonth() {

return getBDayMonth;

}

public void setGetBDayMonth(int getBDayMonth) {

this.getBDayMonth = getBDayMonth;

}

public int getGetBDayDay() {

return getBDayDay;

}

public void setGetBDayDay(int getBDayDay) {

this.getBDayDay = getBDayDay;

}

public String[] getHobby() {

return hobby;

}

public void setHobby(String[] hobby) {

this.hobby = hobby;

}

public String getIntroduce() {

return introduce;

}

public void setIntroduce(String introduce) {

this.introduce = introduce;

}

public void setHobbylist() {

this.hobbylist="";

}

public String getHobbylist() {

this.hobbylist="";



for(int i = 0; i < hobby.length;i++)

this.hobbylist += hobby[i];

return this.hobbylist;



}



}



 

 

[check.jsp]

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

    pageEncoding="EUC-KR"%>

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



<jsp:useBean id="join"  class ="Day5.JoinBean" scope="page"></jsp:useBean>

<jsp:setProperty property="id" name="join" />

<jsp:setProperty property="password" name="join"/>

<jsp:setProperty property="email" name="join"/>

<jsp:setProperty property="name" name="join"/>

<jsp:setProperty property="jumin" name="join"/>

<jsp:setProperty property="year" name="join"/>

<jsp:setProperty property="getBDayMonth" name="join"/>

<jsp:setProperty property="getBDayDay" name="join"/>

<jsp:setProperty property="hobby" name="join"/>

<jsp:setProperty property="introduce" name="join"/>





<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

  

<html>

<head>

<meta charset="EUC-KR">

<title>Insert title here</title>



</script>

</head>

<body>

<center>

<table width="50%">

<tr>

<td>id</td>

<td><jsp:getProperty name="join" property="id"></jsp:getProperty></td>

</tr>

<tr>

<td>password</td>

<td><jsp:getProperty name="join" property="password"></jsp:getProperty></td>

</tr>

<tr>

<td>이메일</td>

<td><jsp:getProperty name="join" property="email"></jsp:getProperty></td>

</tr>

<tr>

<td>이름</td>

<td><jsp:getProperty name="join" property="name"></jsp:getProperty></td>

</tr>

<tr>

<td>주민번호</td>

<td><jsp:getProperty name="join" property="jumin"></jsp:getProperty></td>

</tr>

<tr>

<td>생년월일</td>

<td><jsp:getProperty name="join" property="year"></jsp:getProperty>년

<jsp:getProperty name="join" property="getBDayMonth"></jsp:getProperty>월

<jsp:getProperty name="join" property="getBDayDay"></jsp:getProperty>일</td>

</tr>

<tr>

<td>관심분야</td>

<td><jsp:getProperty name="join" property="hobbylist"></jsp:getProperty></td>

</tr><tr>

<td>자기소개</td>

<td><jsp:getProperty name="join" property="introduce"></jsp:getProperty></td>

</tr>



</table>

</center>

</body>

</html>

 

 

'Servlet & JSP' 카테고리의 다른 글

MVC 패턴  (0) 2019.07.03
JDBC 연결  (0) 2019.06.26
beans 예제  (0) 2019.06.25
REQUEST 예제_SCOPE 안쓰고 데이터 넘기기  (0) 2019.06.24
SESSION 예제_장바구니  (0) 2019.06.24

+ Recent posts