How to get the message in a custom error page (Tomcat)?

后端 未结 6 1956
刺人心
刺人心 2020-12-03 02:53

In JSPs, you may use response.sendError(int code, String message) to return a particular error code (eg 404 for not found) and a message as well. These messages

6条回答
  •  天涯浪人
    2020-12-03 03:22

    I'm sorry for answering so late, but I faced with this problem just a week ago, I've browsed a lot of different sites but nobody really aswered this problem the way I wanted to hear. In this post I found out a few interesting solutions and then came up to my own. Just include this source in your page:

    <%
        out.println(pageContext.getErrorData().getRequestURI());
        out.println("
    "); out.println(pageContext.getErrorData().getStatusCode()); out.println("
    "); out.println(pageContext.getException()); out.println("
    "); %>

    It worked perfectly fine with me.

提交回复
热议问题