在jsp中使用for循环

来源:互联网 发布:科比各项数据排名 编辑:程序博客网 时间:2024/05/21 07:15

<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <base href="<%=basePath%>">
   
    <title>My JSP 'result.jsp' starting page</title>
   
 <meta http-equiv="pragma" content="no-cache">
 <meta http-equiv="cache-control" content="no-cache">
 <meta http-equiv="expires" content="0">   
 <meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
 <meta http-equiv="description" content="This is my page">
 <!--
 <link rel="stylesheet" type="text/css" href="styles.css">
 -->

  </head>
 
  <body>
  <%
  for (int i = 1; i<=9; i++) {
  %>
  <%
  for (int j = 1; j <=i; j++) {
  %>
  <%
   System.out.print(i+"*"+j+"="+i*j+" ");
  %>
  <%
  }
  %>
  <%
  System.out.println("");
  %>
  <%
  }
  %>
  </body>
</html>