新手问一个JSP小问题 请高手指教
<html>
<head><title></title></head>
<body>
<form action="print_table.jsp" method="post">
<table>
<tr>
<td>请输入显示的表格的行数:</td>
<td><input type="text" name="row"></td>
</tr>
<tr>
<td>请输入显示的表格的列数:</td>
<td><input type="text" name="col"></td>
</tr>
<tr>
<td><input type="submit" name="submit" value="提交"></td>
<td><input type="submit" name="reset" value="重置"></td>
</tr>
</table>
</form></body>
</html>
print_table.jsp
<%@ page language="java" contentType="text/html;charset=GB18030"%>
<html>
<head><title></title></head>
<body>
<%
int row=Integer.parseInt(request.getParameter("row"));
int col=Integer.parseInt(request.getParameter("col"));
for(int i=0;i<row;i++)
%>
<table border="1" width="100%">
<tr>
<% for(int j=0;j<col;j++)
{ %>
<td>i*j<%=i*j%></td>
<%
}
%>
</tr>
</body>
</html>
前面调用后面的
错误提示
HTTP Status 500 -
type Exception report
message
description
The server encountered an internal error () that prevented it from fulfilling this request.exception
org.apache.jasper.JasperException: Unable to compile class for JSP:
An error occurred at line: 14 in the jsp file: /jspdemo01/print_table.jsp
i
cannot be resolved11: <tr>
12: <% for(int j=0;j<col;j++)
13: { %>
14: <td><%=i*j%></td>
15: <%
16: }
17: %>
Stacktrace:
org.apache.jasper.compiler.DefaultErrorHandler.javacError(DefaultErrorHandler.java:92)
org.apache.jasper.compiler.ErrorDispatcher.javacError(ErrorDispatcher.java:330)
org.apache.jasper.compiler.JDTCompiler.generateClass(JDTCompiler.java:439)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:349)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:327)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:314)
org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:592)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:317)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:313)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:260)
javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
note The full stack trace of the root cause is available in the Apache Tomcat/6.0.35 logs.
------解决方案--------------------Java code
<table border="1" width="100%">
<%
int row=Integer.parseInt(request.getParameter("row"));
int col=Integer.parseInt(request.getParameter("col"));
int i = 0;
int j = 0;
for(i=0;i<row;i++){
%>
<tr>
<% for(j=0;j<col;j++)
{ %>
<