//返回九九乘法表对应的HTML代码,通过表达式来调用,在页面上显示
String printMultiTable1()
{
String s="";
for(int i=1;i<=9;i++)
{
for(int j=1;j<=i;j++)
{
s+=i+"*"+j+"="+(i*j)+" ";
}
s+="
";//追加换行标签
}
return s;
}
//JSP内置对象out对象,使用脚本方式调用,打印九九乘法表
void printMultiTable2(JspWriter 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("
");//追加换行标签
}
}
%>
九九乘法表
错误页面
HTTP Status 500 – Internal Server Error
Type Exception Report
Message /exercise.jsp (line: 1, column: 84) The JSP specification requires that an attribute name is preceded by whitespace
Description The server encountered an unexpected condition that prevented it from fulfilling the request.
Exceptionorg.apache.jasper.JasperException: /exercise.jsp (line: 1, column: 84) The JSP specification requires that an attribute name is preceded by whitespace
org.apache.jasper.compiler.DefaultErrorHandler.jspError(DefaultErrorHandler.java:42)
org.apache.jasper.compiler.ErrorDispatcher.dispatch(ErrorDispatcher.java:443)
org.apache.jasper.compiler.ErrorDispatcher.jspError(ErrorDispatcher.java:89)
org.apache.jasper.compiler.Parser.parseAttributes(Parser.java:164)
org.apache.jasper.compiler.Parser.parseAttributes(Parser.java:183)
org.apache.jasper.compiler.ParserController.getPageEncodingForJspSyntax(ParserController.java:479)
org.apache.jasper.compiler.ParserController.determineSyntaxAndEncoding(ParserController.java:420)
org.apache.jasper.compiler.ParserController.doParse(ParserController.java:190)
org.apache.jasper.compiler.ParserController.parseDirectives(ParserController.java:119)
org.apache.jasper.compiler.Compiler.generateJava(Compiler.java:194)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:374)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:354)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:341)
org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:660)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:364)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:395)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:339)
javax.servlet.http.HttpServlet.service(HttpServlet.java:731)
org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
Note The full stack trace of the root cause is available in the server logs.
Apache Tomcat/7.0.90