JSP-데이터 송수신 실습 (테이블 생성 활용)

2019년 10월 23일 by Xion

    JSP-데이터 송수신 실습 (테이블 생성 활용) 목차

Send07.jsp

<%@ page contentType="text/html; charset=UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
</head>
<body>
	<h1>JSP를 이용한 데이터 송수신 실습</h1>
	
	<div>
		<h2>Send07.jsp●->Receive07.jsp○</h2>
	</div>
	
	<div>
		<form action="Receive07.jsp" method="post">
			<table class="tbl">
				<tr>
					<th>가로</th>
					<td>
						<input type="text" class="textNumber" name="su1">
					</td>
				</tr>
				<tr>
					<th>세로</th>
					<td>
					<input type="text" class="textNumber" name="su2">
					</td>
					
					
				</tr>
					
					
			</table>
			
					<input type="submit" value="확인">
		
		</form>
	
	</div>
</body>
</html>

Receive07.jsp

<%@page import="com.sun.rowset.internal.InsertRow"%>
<%@ page contentType="text/html; charset=UTF-8"%>
<%
	//데이터 수신
	String su1 = request.getParameter("su1"); 
	String su2 = request.getParameter("su2"); 

	//수신한 데이터 형 변환
	int n1=Integer.parseInt(su1);
	int n2=Integer.parseInt(su2);
	int a=0;

%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
</head>
<body>
<div>
   <table border="1" >
   <%
   for(int i=0; i<n1; i++)
   {%>
      <tr>
      <%
      for(int j=0; j<n2; j++)
      {%>
         <td><%=a %></td>
      <%
         a++;
      }
      %>
      </tr>
   <%}
   %>
   </table>
</div>
</body>
</html>