설명
<%--
# 요청객체 (request-HttpServletRequest의 참조변수)
1. 요청범위에서 데이터를 저장할 수 있다.
request.setAttribute("key",value)
-- MVC 패턴에서 주로 모델데이터를 저장할 때, 사용된다.
2. 요청처리 데이터를 처리할 때, 사용된다.
1) 요청값 url 전달 방식
페이지?id=himan
request.getParameter("id") 형식으로 받아서 himan을
특정변수에 할당할 수 있다.
2) form 형식 전달 방식
- action="이동할 페이지"
- method get 방식/post 방식
- 하위 요소객체에 name="요청key" value="요청값"
- submit 버튼을 통해
이동할페이지? 요청key=요청값
형식으로 전송할 수 있다.
--%>
예제 CODE
<body>
<%
// a02_requestObj.jsp?id=himan
String id = request.getParameter("id");
// ex) url 요청 처리로 name, age, loc를 설정하여
// 요청값을 출력하는 처리를 하세요..
String name = request.getParameter("name");
String age = request.getParameter("age");
String loc = request.getParameter("loc");
%>
<h3 align="center">request객체</h3>
<table>
<tr><th>id 요청값</th></tr>
<tr><td><%=id %></td></tr>
</table>
<h3 align="center">request객체2</h3>
<table>
<tr><th>name 요청</th><th>age 요청</th><th>loc 요청</th></tr>
<tr><td><%=name %></td><td><%=age %></td><td><%=loc %></td></tr>
</table>
</body>