0

In my jsp page some pure java code there i.e, scriptlet. After a long time when refresh it then it is throwing

org.apache.jasper.JasperException: java.lang.NullPointerException 

Sometimes not for a long time also it is throwing same Exception. and the JSP page is displaying empty page. So the user have only one option is Logout. So to avoid that and redirect him to one page that is error page. How to do it ?

4

1 回答 1

2

形式我在这里得到的是,刷新会话值可能会在一段时间后变为 NULL,从而导致NullPointerException.

创建一个名为error page的JSP页面并设置

<%@page isErrorPage="true" %> 

在其他 JSP 页面中,

<%@page errorPage="error.jsp" %>

因此,当您的 JSP 中发生任何运行时错误时,它将重定向到此页面。

注意:如果 JSP 有编译时错误,这不会重定向到错误页面。

于 2012-05-09T07:34:22.167 回答