注册 登录
编程论坛 J2EE论坛

错误检测页面,老是不成功

yuanxl33 发布于 2010-04-18 21:20, 521 次点击
以下三篇程序都在
我怀疑是语法错误,不是我配置问题。

文件名称:check.jsp
<%@ page language="java" contentType="text/html; charset=GBK" errorPage="error.jsp" %>
    <html><head>
        <title>错误异常检测页面</title>
    </head>
    <body>
        <center>
            <br><h1>
                <%
                int checki=0;
                int checkor=0;
                int result=0;
                try{
                checki=Integer.parseInt(request.getParameter("value1"));
                }
                catch(NumberFormatException nfex){
                throw new NumberFormatException("被除数不是整数!");
                }
                try{
                checkor=Integer.parseInt(request.getParameter("value2"));
                }
                catch(NumberFormatException nfex){
                throw new NumberFormatException("除数不是整数!");
                }
                result=checki/checkor;
                out.println("<h3>正确运算结果:<hr></h3>");
                out.println(checki+"/"+checkor+"="+result);
                %>
            </h1>
                    <a href="javascript:history.back();">返回</a>
        </center>
    </body>
</html>


文件名称:error.jsp
<%@page language="java" isErrorPage="true" contentType="text/html;charset=GB2312" %>
<html>
    <head>
        <title>错误处理页面</title>
    </head>
    <body bgcolor="#ffffff">
        <div aglin="center">
            <br>
            <h1>错误信息<h1>
                <hr>
                <p><center>
                    <h3><%=exception.toString()%></h3>
                        <a href="javascript:history.back();">返回</a>
                    </center>
                </p>
            </div>
        </body>
    </html>

文件名称: compute.htm
<html>
    <head>
        <title>除法运算--JSP中处理异常</title>
    </head>
    <body bgcolor="#ffffff">
        <div align="center">
            <form action="check.jsp" method="post" target="_self">
                ———— 整 数 除 法 运 算 ————<br>
                    <p>被除数:<input type="text" name="value1">
                        除数:<input type="text" name="value2">
                    </P>
                    <p>
                        <input type="submit" name="submit" value="计算">
                    </p>
          </form>
    </div>
        </body>
    </html>
3 回复
#2
linjx01232010-04-19 09:02
可以运行,应该是你配置出错了,最好把错误信息贴上来
#3
yuanxl332010-04-19 16:36
你输入一个非整数看看

错误信息我不是不想发。是没办法发

直接提示网页有问题无法显示。http 500 - 内部服务器错误
JDK 1.506 TOMCAT 5.5.28

[ 本帖最后由 yuanxl33 于 2010-4-19 16:38 编辑 ]
#4
yuanxl332010-04-19 16:43
直接运行error.jsp 看到的
description The server encountered an internal error () that prevented it from fulfilling this request.

exception

org.apache.jasper.JasperException
    org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:460)
    org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:373)
    org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:329)
    org.apache.jasper.servlet.JspServlet.service(JspServlet.java:265)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:729)


root cause

java.lang.NullPointerException
    org.apache.jsp.error_jsp._jspService(error_jsp.java:59)
    org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:98)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:729)
    org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:331)
    org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:329)
    org.apache.jasper.servlet.JspServlet.service(JspServlet.java:265)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:729)


note The full stack trace of the root cause is available in the Apache Tomcat/5.5.28 logs.
1