joinform.jsp
<%@ 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>
<h3>회원가입</h3>
<form action="form_process.jsp" name="member" method="post">
<P> 아이디 : <input type="text" name="id"> <input type="button" value="아이디 중복검사"></P>
<P> 비밀번호 : <input type="password" name="passwd"></P>
<P> 이름 : <input type="text" name="name"></P>
<P> 연락처 : <select name="phone1">
<option value="010">010</option>
<option value="011">011</option>
<option value="016">016</option>
<option value="017">017</option>
<option value="019">019</option>
</select> -
<input type="text" maxlength="4" size="4" name="phone2"> -
<input type="text" maxlength="4" size="4" name="phone3"></P>
<p> 성별 : <input type="radio" name="sex" value="남성" checked>남성
<input type="radio" name="sex" value="여성">여성</p>
<p> 취미 : 독서<input type="checkbox" name="hobby" value="독서"checked>
운동<input type="checkbox" name="hobby" value="운동">
영화<input type="checkbox" name="hobby" value="영화"></p>
<p> <textarea name="comment" cols="30" rows="3" placeholder="가입인사를 입력해주세요"></textarea></p>
<p> <input type="submit" value="가입하기">
<input type="reset" value="다시쓰기"></p>
</form>
</body>
</html>
form_process.jsp
<%@ 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");
String id = request.getParameter("id");
String passwd = request.getParameter("passwd");
String name = request.getParameter("name");
String phone1 = request.getParameter("phone1");
String phone2 = request.getParameter("phone2");
String phone3 = request.getParameter("phone3");
String sex = request.getParameter("sex");
String[] hobby = request.getParameterValues("hobby");
String comment = request.getParameter("comment");
%>
<p> 아이디 : <%=id %> <!-- 가져온 id의 정보를 나타냄 -->
<p> 비밀번호 : <%=passwd %>
<p> 이름 : <%=name %>
<p> 연락처 : <%=phone1 %>-<%=phone2 %>-<%=phone3 %>
<p> 성별 : <%=sex %>
<p> 취미 : <%
if(hobby != null) {
for(int i = 0; i < hobby.length; i++) {
out.println(" " + hobby[i]);
}
}
%>
<br>
<%
StringBuffer hobbyStr = new StringBuffer();
if (hobby != null) {
for (String s : hobby) {
hobbyStr.append("|" + s);
}
out.println(hobbyStr);
}
%>
<p> 가입인사 : <%=comment %>
</body>
</html>