站内搜索: 请输入搜索关键词

当前页面: 开发资料首页JSP 专题放在同一个目录下的JSP程序,有的运行正常,有些则出现这样的错误提示,请问是怎么回事?

放在同一个目录下的JSP程序,有的运行正常,有些则出现这样的错误提示,请问是怎么回事?

摘要: 放在同一个目录下的JSP程序,有的运行正常,有些则出现这样的错误提示,请问是怎么回事?


有其中的几个JSP不能运行,其中一个的错误提示如下,请问怎么处理?:

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
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:372)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:292)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:236)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)


root cause

java.lang.NullPointerException
org.apache.jsp.error_jsp._jspService(error_jsp.java:60)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:94)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:324)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:292)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:236)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)


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


--------------------------------------------------------------------------------

Apache Tomcat/5.0.30


程序的代码如下,而且我发现错误的根源是在

<%= exception.toString() %>

这一句:
<%@ page language="java" isErrorPage="true" contentType="text/html;charset=GBK"%>


<head>
Compute error
</head>
<body bgcolor="#FFFFFF">




错误信息





<%= exception.toString() %>

//问题由这引起




返回



</body>




你上面这个页面没有抛出异常,也就是说exception的值为null
当访问一个空对象的方法时就会抛出上面这个错误.


这段代码是一本书上的例子,我还以为是我机器的环境问题。

请问楼上应当怎么解决? 我该开始学,还不怎么入门,谢谢!


i lost my chinese input system.so in english, i'm sorry.

this jsp page is not used to access directly. it just use to handle or display some exception. when you access some other page and a exception occur, a exception object is created and set to request or session ,and then the program redirect or forward to this page with the exception passed in, in this page "exception.toString()" execute correctly.
but when you access this jsp page directly,there is not a exception object,so the "exception.toStrint()" invoking failed, just a null pointer exception ,for therer is not a exception object.



你在处理try..catch块的时候,有错误就转到这个错误页面,否则就正常执行就OK了


楼主这个页面应该是从一个别的页面转来的吧!
exception这个参数是什么,据我估计应该是你在别的页面转过来一个这样的参数,如果没有转过来的话,肯定是会错的,因为exception根本就不存在,所以肯定会有空指针异常了!




调用空对象,好好检查代码,变量定义的时候最好同时初始化它


exception.toString()

这个变量都没有啊 ,你是用什么开发TOOL的?应该提示你有错误啊


↑返回目录
前一篇: 关于tomcat运行servlet的问题
后一篇: 多个表的数据合为一个表,会不会增加MYSQL的压力?????