Multiple web.xml error code configuration

I would like to forward all errors to my Errorsevlet without explicitly specifying all codes. Is there any way to do this?

<error-page>
   <error-code>400</error-code>
   <location>/servlet/com.abc.servlet.ErrorServlet</location>
</error-page>

** And after reaching the ErrorServlet, how can I get a trace of the error stack in the servlet. So that I can send emails when one error occurs. **

+3
source share
4 answers
<error-page>
    <exception-type>java.lang.Throwable</exception-type> 
    <location>/servlet/com.ibm.eisa.servlet.ErrorServlet</location> 
</error-page>

Try this, all your errors will be caught (500), not 404, etc.

0
source

, Servlet 3.0 , , (, 404, 401 ..). <error-code> <exception-type> , <location>.

<error-page>
   <location>/errorServlet</location>
</error-page>

, URL-, Tomcat InvokerServlet.

+11

, . , list.

stacktrace (, , ), - :

<%@ page isErrorPage="true" import="java.io.*"%>
<body>
<p>Sorry, there was an error.</p>
<!-- The full stacktrace follows:-->
<!-- 
<%
if (exception != null) {
    exception.printStackTrace(new PrintWriter(out));
}
%> 
-->
</body>
+2

, , , , Servlet 3.0.

, " " " " XSD, , " " " ".

(, GlassFish) , , , , .

WebLogic 12c, GlassFish. Tomcat.

See: bz.apache.org/bugzilla/show_bug.cgi?id=52135

0
source

Source: https://habr.com/ru/post/1732188/


All Articles