<%@ page language="java" contentType="text/html; charset=EUC-KR"
    pageEncoding="EUC-KR"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=EUC-KR">
<title>Insert title here</title>
</head>
<body>
<form>
행 : <input type="text" name="rows"></p>
열 : <input type="text" name="cols"></p>
<input type="submit" value="확인"></p>
</form>
<%
int rows =1, cols=1;
//만약 폼변수 rows과 cols가 null이 아니라면.
if(request.getParameter("rows") != null && request.getParameter("cols") != null)
{
 if(request.getParameter("rows") != "" && request.getParameter("cols") != "")
 {
  rows=(new Integer(request.getParameter("rows")).intValue());
  cols=Integer.parseInt(request.getParameter("cols"));
 }
}
%>
<table border="1" width="640">
<%
//반복할것 (1부터 rows까지)
for(int i=1;i<rows+1;i++)
{
 %>
 <tr>
 <%
 //반복할것 (1부터 cols까지)
 for(int j=1;j<cols+1;j++)
 {
 %>
  <td><%= i %>X<%= j %>=<%= i*j %></td>
 <%
 }
 %>
 </tr>
<%
}
%>
</table>

</body>
</html>

Posted by 말없제이
,