일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | |||||
3 | 4 | 5 | 6 | 7 | 8 | 9 |
10 | 11 | 12 | 13 | 14 | 15 | 16 |
17 | 18 | 19 | 20 | 21 | 22 | 23 |
24 | 25 | 26 | 27 | 28 | 29 | 30 |
31 |
- #자바스크립트#접속시간#시간
- #jQuery#mouse#over
- #C언어#for#간단#예제
- #getElementById#id
- #select#from#distinct
- #자바스크립트#만년달력#달력
- #클릭#숨기기#보이기
- #자바스크립트#텍스트#알람#alert
- #C언어#do#while#계산기
- #C언어#사각형
- #자바스크립트#회원가입#유효성#검사
- #db#join#inner#cross
- #증감#연산자
- #자바스크립트#alert
- #alert#자바스크립트#radio#check
- #C언어#타입#printf
- #html#프레임
- #db#order#by
- #C언어#do#while#계산기#함수
- #db#froup#by
- #C언어#숫자비교#삼항연산자
- #자바스크립트#시계#실시간시계
- #C언어#scanf#fflush
- #C언어#성적처리#점수#등급
- #db#where
- #C언어#switch#case#계산기#함수
- #html#테이블#table
- #C언어#if
- #alert#자바스크립트#checkbox#alert
- #db#데이터베이스#select
- Today
- Total
선택장애
JSP - request사용하기 (select와 checkbox값받기) 본문
request_test.jsp
<%@ page language="java" contentType="text/html; charset=EUC-KR"
pageEncoding="EUC-KR"%>
<!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 name="form1" method="post" action="request_test2.jsp">
<center>
<h1>request 테스트 폼</h1>
<hr>
<table border="1">
<tr>
<td>이름
</td>
<td><input type="text" name="username">
</td>
</tr>
<tr>
<td>직업
</td>
<td>
<select name="job">
<option value="학생">학생</option>
<option value="학생2">학생2</option>
<option value="학생3">학생3</option>
<option value="학생4">학생4</option>
</select>
</td>
</tr>
<tr>
<td>관심분야
</td>
<td>
<input type="checkbox" name="hobby" value="정치">정치
<input type="checkbox" name="hobby" value="사회">사회
<input type="checkbox" name="hobby" value="정보통신">정보통신
</td>
</tr>
<tr>
<td colspan="2">
<input type="submit" value="확인">
<input type="reset" value="취소">
</td>
</tr>
</table>
</center>
</form>
</body>
</html>
값을 받을 request_test2.jsp
//아이디값이 아니고 name값을 주어야한다
<%@ page language="java" contentType="text/html; charset=EUC-KR"
pageEncoding="EUC-KR"%>
<% request.setCharacterEncoding("euc-kr");%>
<!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>
<h1>결과</h1>
<hr>
<table border="1"></table>
<tr>
<td>이름</td>
<td><%=request.getParameter("username") %></td>
//이름의 name값을 받는다.
<tr>
<td>직업</td>
<td><%=request.getParameter("job") %></td>
//직업의 name값을 받는다.
<tr>
<td>관심분야
<td>
<% String[] hobby = request.getParameterValues("hobby");
if (hobby != null) {
for (int i = 0; i < hobby.length; i++)
{ out.println(hobby[i]); } // for
} // if %>
//체크박스
</td>
</body>
</html>
'JSP' 카테고리의 다른 글
JSP - 장바구니(물건추가, 로그아웃)Session (0) | 2017.08.14 |
---|---|
JSP - Application(name이름넘기기, count값 올리기) (0) | 2017.08.14 |
JSP - Sesstion(alert) (0) | 2017.08.14 |
JSP - Forward_Action, response.sendRedirect (0) | 2017.08.14 |