728x90
반응형
08_05_01_request01.jsp
08_05_01_request01_process.jsp
08_05_01_request01.jsp <%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%> <% String ids = request.getParameter("id")!=null? request.getParameter("id"):"아이디 없음"; %> <!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title>Insert title here</title> </head> <body> <form action="08_05_01_request01_process.jsp" method="get"> <!-- <form action="08_05_01_request01_process.jsp" method="post"> --> <!-- <form method="get"> --> <p> 아 이 디 : <input type="text" name="id" value="<%=ids %>"></p> <p> 비밀번호 : <input type="password" name="passwd"></p> <input type="submit" value="전송"/> </form> </body> </html>
08_05_01_request01_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> <p>아이디 : <%=request.getParameter("id")%></p> <p>이름 : <%=request.getParameter("name")%></p> <p>비밀번호 : <%=request.getParameter("passwd()")%></p> <p>비밀번호 : <%=request.getParameter("passwd")%></p> </body> </html>
08_05_01_request02.jsp
08_05_01_request02_process.jsp08_05_01_request02.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> <form action="08_05_01_request02_process.jsp" method="post"> <p> 아 이 디 : <input type="number" name="user_id"></p> <!-- <p> 아 이 디 : <input type="number" name="id"></p> --> <!-- form태그내 입력요소의 name속성 .dto 멤버클래스 이름 datebase테이블의 컬럼명 (대소문자x) 일치시켜야 함 --> <p> 이름 : <input type="text" name="name"></p> <p> 취미 : <label><input type="checkbox" name="hobby" value="독서" >독서</label> <label><input type="checkbox" name="hobby" value="운동" >운동</label> <label><input type="checkbox" name="hobby" value="영화" >영화</label> </p> <input type="submit" value="전송"/> </form> </body> </html>
08_05_01_request02_process.jsp <%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%> <%-- <%@ page import="com.dto.MemberBean" %> --%> <!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title>Insert title here</title> </head> <body> <% request.setCharacterEncoding("utf-8"); %> <%-- <% MemberBean memberBean = new MemberBean(); %> --%> <jsp:useBean id="memberBean" class="com.dto.MemberBean"/> <%-- <jsp:setProperty name="memberBean" property="*"/> --%> <jsp:setProperty name="memberBean" property="id" param="user_id"/> <!-- param ="user_id" => request.getParameter("user_id") => 1 name="memberBean" jsp:setProperty property="id" 조합 =>memberBean.setId(request.getParameter("user_id")); =>memberBean.setId(1); --> <jsp:setProperty name="memberBean" property="name" param="name"/> <!-- memberBean.setName(request.getParameter("name")) --> <jsp:setProperty name="memberBean" property="hobby" param="hobby"/> <!-- memberBean.setHobby(request.getParameterValues("hobby")) --> <!-- new String[] {"독서","운동"{ &2 --> 아이디 : <jsp:getProperty name="memberBean" property="id"/><br> <!-- memberBean.getId() --> 이름 : <jsp:getProperty name="memberBean" property="name"/><br> <!-- memberBean.getName() --> 취미 : <jsp:getProperty name="memberBean" property="hobby"/><br> 요청정보 컨텐츠타입 = <%=request.getContentType() %><br> 세션아이디 = <%=request.getRequestedSessionId() %><br> <small style="color:red">클라이언트가 전송한 요청 정보(post로 보낸 데이터만)의 컨텐츠 타입을 구함. String으로 반환</small><br> <% String[] hobby = memberBean.getHobby(); out.print("방갯수: " + hobby.length + "<br>"); out.print("[0]: " + hobby[0] + "<br>"); out.print("[1]: " + hobby[1] + "<br>"); // out.print("[2]: " + hobby[2] + "<br>"); // hobby값이 3개가 아니면 해당값은 오류남 for(int i = 0; i < hobby.length; i++){ if(hobby[i] != null){ out.write(hobby[i]); if(i != (hobby.length-1)) out.write(", "); }else{ if(i == 0) out.write("입력된 취미 정보가 확인되지 않습니다."); } } %> </body> </html>
728x90
반응형
'[JAVA]' 카테고리의 다른 글
[JSP] URI, URL, URN (0) | 2024.03.14 |
---|---|
[JSP] Enumeration - form, table (0) | 2024.03.14 |
[JSP] 06_08_include.jsp - include를 이용한 header, footer (0) | 2024.03.13 |
[JSP] 08_01_.jsp - 액션태그 <jsp:include / forward> (0) | 2024.03.13 |
[JSP] 03_01_scriptlet.jsp - 덧셈, 짝수 (0) | 2024.03.12 |