test2.html
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=EUC-KR">
<title>Insert title here</title>
</head>
<body>
<form action="test2.jsp" method="post">
이름 : <input type="text" name="name"><br>
주소 : <input type="text" size="50" name="addr"><br>
직업 : <input type="radio" name="job" value="학생">학생
<input type="radio" name="job" value="직장인">직장인
<input type="radio" name="job" value="전문직">전문직
<input type="radio" name="job" value="기타">기타
<br>
취미 : <input type="checkbox" name="hobby" value="독서">독서
<input type="checkbox" name="hobby" value="영화감상">영화감상
<input type="checkbox" name=hobby" value="게임">게임
<input type="checkbox" name=hobby" value="자전거">자전거
<input type="checkbox" name=hobby" value="벽보기">벽보기
<br>
<input type="submit" value="보내기"/>
</form>
</body>
</html>
test2.jsp
<%@ page language="java" contentType="text/html; charset=EUC-KR"
pageEncoding="EUC-KR"%>
<%!
String name,addr,job;
String[] hobby;
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=EUC-KR">
<title>Insert title here</title>
</head>
<body>
<%
//받기전 한글처리
request.setCharacterEncoding("euc-kr");
//파라메터 값 받기
name = request.getParameter("name");
addr = request.getParameter("addr");
job = request.getParameter("job");
hobby = request.getParameterValues("hobby");
out.println("name : ");
out.println(name+"<br>");
%>
addr : <%=addr%><br>
job : <%=job%><br>
hobby :
<%--<%for (String n : hobby)out.println(n + "<br>");%> --%>
<%
for(String n: hobby){
%>
<%=n %>
<%--JSP주석 : 현재 영역은 html영역이지만 for문 영역에 포함되는 곳이다.--%>
<%
} //end for
%>
</body>
</html>
'Programing > JSP' 카테고리의 다른 글
JSP - page, session, application 간의 차이 (0) | 2008.07.29 |
---|---|
JSP - Bean활용 (0) | 2008.07.29 |
JSP - forward (2) | 2008.07.29 |
JSP - include (0) | 2008.07.29 |
JSP - JSP입문 (0) | 2008.07.29 |