📆 Today I Learned(개발언어학습)/JSP
Day02(테이블안에 구구단 만들기 !)
JinSeong
2021. 10. 5. 19:24
<%@ 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>
<%!
public String guguGaro(){
StringBuffer sb = new StringBuffer();
sb.append("<table border='1px'>");
for(int i=2; i<10; i++){
sb.append("<tr>");
for(int j=1; j<10; j++){
sb.append("<td>");
sb.append(i + "x" + j + "=" + (i*j));
sb.append("</td>");
}
sb.append("</tr>");
}
String result = sb.toString();
return result;
}
public String guguSero(){
StringBuffer sb = new StringBuffer();
sb.append("<table border='1px'>");
for(int i=2; i<=9; i++){
sb.append("<tr>");
for(int j=2; j<=9; j++){
sb.append("<td>");
sb.append(j + "x" + i + "=" + (i*j));
sb.append("</td>");
}
sb.append("</tr>");
}
String result = sb.toString();
return result;
}
%>
<%=guguGaro() %>
<hr>
<%=guguSero() %>
</body>
</html>
출력내용
