期望输出:
java.lang.Exception:被除数不能为0
但是,出了4个错!type Exception reportmessage description The server encountered an internal error () that prevented it from fulfilling this request.exception org.apache.jasper.JasperException: Unable to compile class for JSPAn error occurred at line: 8 in the jsp file: /myjsp/divide.jspGenerated servlet error:
[javac] Compiling 1 source fileD:\Apache Group\Tomcat 4.1\work\Standalone\localhost\_\myjsp\divide_jsp.java:59: '(' expected
{
^An error occurred at line: 24 in the jsp file: /myjsp/divide.jspGenerated servlet error:
D:\Apache Group\Tomcat 4.1\work\Standalone\localhost\_\myjsp\divide_jsp.java:66: <identifier> expected
out.write("\r\n");
^An error occurred at line: -1 in the jsp file: nullGenerated servlet error:
D:\Apache Group\Tomcat 4.1\work\Standalone\localhost\_\myjsp\divide_jsp.java:30: 'try' without 'catch' or 'finally'
try {
^
D:\Apache Group\Tomcat 4.1\work\Standalone\localhost\_\myjsp\divide_jsp.java:79: '}' expected
^
4 errors
java.lang.Exception:被除数不能为0
但是,出了4个错!type Exception reportmessage description The server encountered an internal error () that prevented it from fulfilling this request.exception org.apache.jasper.JasperException: Unable to compile class for JSPAn error occurred at line: 8 in the jsp file: /myjsp/divide.jspGenerated servlet error:
[javac] Compiling 1 source fileD:\Apache Group\Tomcat 4.1\work\Standalone\localhost\_\myjsp\divide_jsp.java:59: '(' expected
{
^An error occurred at line: 24 in the jsp file: /myjsp/divide.jspGenerated servlet error:
D:\Apache Group\Tomcat 4.1\work\Standalone\localhost\_\myjsp\divide_jsp.java:66: <identifier> expected
out.write("\r\n");
^An error occurred at line: -1 in the jsp file: nullGenerated servlet error:
D:\Apache Group\Tomcat 4.1\work\Standalone\localhost\_\myjsp\divide_jsp.java:30: 'try' without 'catch' or 'finally'
try {
^
D:\Apache Group\Tomcat 4.1\work\Standalone\localhost\_\myjsp\divide_jsp.java:79: '}' expected
^
4 errors
改成如下:
<HTML>
<HEAD>
<TITLE>Divide by zero!</TITLE>
</HEAD>
<BODY>
<% int a = 2, b = 0, c;
try
{
if(0==b)
{
throw new Exception("被除数不能为0");
}
c = a/b;
}
catch(Exception e)
{
%><p><%=e.toString()%></p><%
}
finally
{}
%></BODY>
</HTML>
<%@ page contentType="text/html;charset=GBK"%>
<HTML>
<HEAD>
<TITLE>Divide by zero!</TITLE>
</HEAD>
<BODY>
<% int a = 2, b = 0, c;
try
{
if(0==b)
{
throw new Exception("被除数不能为0");
}
c = a/b;
}
catch(Exception e)
{
%><p><%=e.toString()%></p><%
}
finally
{}
%></BODY>
</HTML>
哦,对!我晕啊这么简单的错误,没注意到那么,如何调试JSP程序呢????
--------------------------------
eclipse可以设置jsp/servlet断点吗?avi11lang(萧十一郎) :
我用的就是JDK + Tomcat,怎么调试呢?
如果你把tomcat安装在c:\tomcat目录下
则运行C:\>tomcat\bin\startup.bat
然后把你的文件COPY到C:\>tomcat\webapps\root目录下
在浏览器地址栏中输入
http://localhost:tomcat安装时设置的端口号(默认是8080)/你的文件名
回车
--------------------------------------------
看到那些文件了!
那如何调试呢?(怎么找出我jsp文件中出错的位置?)
<%@ page contentType="text/html;charset=gb2312" %>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312"><HTML>
<HEAD>
<TITLE>Divide by zero!</TITLE>
</HEAD>
<BODY>
<% int a = 2, b = 0, c;
try
{
if(0==b)
{
throw new Exception("被除数不能为0");
}
c = a/b;
}
catch(Exception e)
{
%><p><%=e.toString()%></p><%
}
%></BODY>
</HTML>