简体   繁体   中英

how to display stack trace instead of 500 internal server error on weblogic

I was working with tomcat 7 and when an exception is thrown the stack trace is shown in the browser. But now I'm using WebLogic 12. Occasionally, I'll get the message "Error 500--Internal Server Error" appear in my web browser when something has gone wrong and I have to look in the log files for the stack trace of the exception. How can I get the exception to be output directly to my browser?

FrontEnd Angular. BackEnd Java.

The best way is to create a custom error page (jsp) and declare it in the web.xml file. For instance:
<error-page> <error-code>500</error-code> <location>myCustomError500.jsp</location> </error-page>
You can specify a jsp or an html page In your case, create a new JSP. It must have this attribute:
<%@ page isErrorPage= "true" %> Inside your jsp, use the built-in exception object to get the error message:
<%= exception %>
For the stack trace:
exception.printStackTrace(new java.io.PrintWriter(out));

The solution is to configure a http filter and intercept the exception then send the message to the frontEnd. In prod mode we cant show stack trace.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM