把你的错误信息存在session里,然后在catch{}里最后做一个跳转
response.sendRedirect("/error.jsp");
error.jsp取session显示错误信息这是简单的方法之一,

解决方案 »

  1.   

    你可以在页面中设置error.jsp错误页,并在error.jsp中指定iserrorpage="true",一般error中的代码很简单,如下:
    <%@ page contentType="text/html; charset=gb2312" language="java" import="java.sql.*" isErrorPage="true" %>
    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=gb2312">
    <title>错误信息页</title>
    </head><body bgcolor="buttonface">
    <table width="60%" align=center border=0 cellspacing=0 cellpadding=0>
    <tr height=35><td colspan=2 align=center style="font:14px;font-weight:600;">系统出错报告</td></tr>
    <tr height=35><td colspan=2 align=left style="font:14px">应用程序异常出错!</td></tr>
    <tr height=35><td colspan=2 align=left style="font:14px">错误信息:</td> </tr>
    <tr><td colspan=2 style="color:red">&nbsp;&nbsp;&nbsp;&nbsp;<%=exception.getMessage()%></td></tr>
    <tr height=60><td colspan=2></td></tr>
    <tr height=60>
    <td align=center><input type=button hidefocus style="font:14px" name=btnreturn value="后  退"></td>
    <td align=center><input type=button hidefocus style="font:14px" name=btnreLogin value="重新登录"></td>
    </tr>
    </body>
    </html>
      

  2.   

    那是因为你在有抛出错误的地方没有调用try块的原因。
    try{
      }
     catch(Exception e){
      out.println(e.getMessage());
    }
      

  3.   

    我们在项目中,错误面一般中这么写
    <%@ page contentType="text/html; charset=utf-8" language="java" errorPage="" isErrorPage="true" %>
    <html>
    <head>
    <title>错误面</title>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
    </head><body>
    <%
        out.println(exception.toString());
        exception.printStackTrace();
    %>
    </body>
    </html>其它页面只需将errorPage指定到些错误页即可
      

  4.   

    ■■上面各位,这样仍然不能捕获tomcat服务器的HTTP 404和500的系统错误啊,仍然显示的是系统错误页面,没有显示error.jsp,请再继续。。■■