728x90
반응형

08_05_02_form05.jsp
08_05_02_form05_process.jsp
08_05_02_form05.jsp

<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>08_05_02_form05.jsp</title>
</head>
<body>
<h3>회원가입</h3>
	<form action="08_05_02_form05_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" selected>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="gender" value="남성" checked>남성
			<input type="radio" name="gender" 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>
08_05_02_form05_process.jsp

<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>08_05_02_form05_process.jsp</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 gender = request.getParameter("gender");
		String[] hobby = request.getParameterValues("hobby");
		String comment = request.getParameter("comment");
	%>
	<p>아이디 : <%=id %></p>
	<p>비밀번호 : <%=passwd %></p>
	<p>이름 : <%=name %></p>
	<p>연락처 : <%=phone1 %>-<%=phone2 %>-<%=phone3 %></p>
	<p>성별 : <%=gender %></p>
	<p>취미 : 
	<%
	if (hobby != null) {
		for (int i = 0; i < hobby.length; i++) {
			out.println(" "+hobby[i]);
		}
	}else{
		out.print("선택한 취미가 없습니다.");
	}
	
	
	%>
	</p>
	<p>가입 인사 : <%=comment %></p>
</body>
</html>

 

08_05_02_form06.jsp
08_05_02_form06_process.jsp
08_05_02_form06_process.jsp

<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
    <%@ page import="java.io.*, java.util.*" %>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>08_05_02_form04_process.jsp</title>
</head>
<body>
	<table border="1">
		<tr>
			<th>요청 파라미터 이름</th>
			<th>요청 파라미터 값</th>
		</tr>
		<%
			request.setCharacterEncoding("utf-8");
			Enumeration<String> paramNames = request.getParameterNames();
			while (paramNames.hasMoreElements()){
				String name = paramNames.nextElement();
				out.print("<tr><td>" + name + "</td>\n");
				String paramValue = request.getParameter(name);
				out.println("<td> "+ paramValue + "</td></td>\n");
			}
		%>
	
	</table>
</body>
</html>​
08_05_02_form06.jsp

<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>08_05_02_form04.jsp</title>
</head>
<body>
<h3>회원가입</h3>
	<form action="08_05_02_form06_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="phone">
				<option value="010" selected>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="gender" value="남성" checked>남성
			<input type="radio" name="gender" 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>

취미 독서,운동,영화 중 1건만 표기됨

Enumeration 

Enumeration paramEnum = request.getParameterNames();
// Enumeration : 값을 가져와서 붙여준다.
(자료형 미지성시 object로 가져와짐 // getParameterNames : 요소들만 떼와라)
<%@ page import="java.util.Enumeration, java.util.Map" %>
while(paramEnum.hasMoreElements()){ //떼어올 요소들이 있는지?
728x90
반응형

+ Recent posts