<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
</head>
<body>
<h1>생성할 행, 열 수를 입력해주세요.</h1>
<form action="ex09makeTable.jsp">
행 : <input type="number" name="hang"> <br>
열 : <input type="number" name="yeol"> <br>
<input type="submit" value="생성">
</form>
</body>
</html>
<%@ 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>
<%-- 1. html에서 form 태그 3요소 채우기 --%>
<%-- 2. 파라미터 수집 --%>
<%
int hang = Integer.parseInt(request.getParameter("hang"));
int yeol = Integer.parseInt(request.getParameter("yeol"));
int cnt = 0;
int[][] arr = new int[hang][yeol];
%>
<%-- 3. 테이블 출력 --%>
<table border="1">
<%for(int i=0; i<hang; i++) {%>
<tr>
<%for(int j=0; j<yeol; j++) {%>
<% cnt++;
arr[i][j] = cnt;%>
<td><%=arr[i][j] %></td>
<%} %>
</tr>
<%} %>
</table>
</body>
</html>
'Java > JSP&Servlet' 카테고리의 다른 글
[JSP] response (0) | 2022.05.16 |
---|---|
[JSP] 랜덤한 숫자를 입력 받은 뒤 랜덤 뽑기 (0) | 2022.05.15 |
[JSP] 성적확인프로그램(평균,학점) (0) | 2022.05.15 |
[JSP] html에서 JSP로 데이터 보내기 (0) | 2022.05.15 |
[JSP] taglib (0) | 2022.05.15 |