<%@ page language="java" contentType="text/html; charset=utf-8"%>
<!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=utf-8">
<title>MultiplicationTable</title>
</head>
<body>
<%!
//通过表达式调用返回九九乘法表
String PrintMultiTable1(){
String s="";
for(int i=1;i<=9;i++){
for(int j=1;j<=i;j++){
s+= i+"*"+j+"="+(i*j)+" ";
}
s+="<br>";//追加换行标签
}
return s;
}
//使用脚本方式调用,打印九九乘法表
void PrintMultiTable2(JspWrite out)
throws Exception
{
for(int i=1;i<=9;i++){
for(int j=1;j<=i;j++){
out.println(i+"*"+j+"="+(i*j)+" ");
}
out.println("<br>");//追加换行标签
}
}
%>
<h2>乘法表</h2>
<hr>
<%=PrintMultiTable1() %>
]<hr>
<% PrintMultiTable2(out); %>]
</body>
</html>