How can I print error stack trace in JSP page?

后端 未结 9 2136
说谎
说谎 2020-12-01 17:50

I have set my error page like this in web.xml:

 
  java.lang.Exception
  /erro         


        
9条回答
  •  情深已故
    2020-12-01 18:34

    May be it helps to you..
    it will be show exception StackTrace into browser

    exception.printStackTrace(response.getWriter());  
    

    Or

    <%
      try{
         int test = Integer.parseInt("hola");
      }catch(Exception e){
         **// HERE THE MAGIC BEGINS!!**
         out.println("
    "); e.printStackTrace(new java.io.PrintWriter(out)); out.println("
    "); **// THE MAGIC ENDS!!** } %>

    If you declare <% page isErrorPage="true" %> in top of error.jsp, then you have access to the thrown Exception (and thus also all of its getters) by ${exception}

    Message: ${exception.message}

    see more.. Mapping Errors to Error Screens

提交回复
热议问题