반응형
두번째 jsp페이지에서 request.sendRedirect를 사용해서 넘기기
requestTestForm.jsp
center_jsp.jsp
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 32 33 34 35 36 37 38 39 | <%@ page language="java" contentType="text/html; charset=EUC-KR" pageEncoding="EUC-KR"%> <!DOCTYPE html> <html> <head> <meta charset="EUC-KR"> <title>Insert title here</title> </head> <body> <form name="form1" method="get" action="center_jsp.jsp"> <table align=center border=1px> <tr> <td>이름</td> <td><input type="text" name="userName"></td> </tr> <tr> <td>전화번호</td> <td><input type="text" name="tel"></td> </tr> <tr> <td>직업</td> <td> <select name="job"> <option selected>무직</option> <option>전문직</option> <option>학생</option> <option>기타</option> </select> </tr> <tr> <td colspan=2> <input type="submit" value="제출"> <input type="reset" value="취소"> </td> </tr> </table> </form> </body> </html> | cs |
center_jsp.jsp
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 | <%@ page language="java" contentType="text/html; charset=EUC-KR" pageEncoding="EUC-KR"%> <% request.setCharacterEncoding("euc-kr"); %> <!DOCTYPE html> <html> <head> <meta charset="EUC-KR"> <title>Insert title here</title> </head> <body> <% String userName = request.getParameter("userName"); String tel = request.getParameter("tel"); String job = request.getParameter("job"); response.sendRedirect("receiptForm.jsp?" +"userName="+userName +"&tel="+tel +"&job="+job); %> </body> </html> | cs |
receiptForm.jsp
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 | <%@ page language="java" contentType="text/html; charset=EUC-KR" pageEncoding="EUC-KR"%> <!DOCTYPE html> <html> <head> <meta charset="EUC-KR"> <title>Insert title here</title> </head> <body> 이름 : <%= request.getParameter("userName") %> <br> 전화번호 : <%= request.getParameter("tel") %> <br> 관심분야 : <%= request.getParameter("job") %> <br> </body> </html> | cs |
반응형
'Web > JSP' 카테고리의 다른 글
[JSP] 장바구니 구현 (0) | 2018.08.17 |
---|---|
[JSP] scope 범위 (0) | 2018.08.17 |
[JSP] Get방식 Post방식 한글 깨짐 처리 방법 (0) | 2018.08.17 |
[JSP] 에러 종류 (0) | 2018.08.17 |