ErrorPage Web.xml protect your stack trace

Java APP & Web contaner :
IMHO you should use settings for protect your web content from outside. I mean you have to hide service information of your web-site like : error page 400,403,404,500,503…

Settings per virtual domain :
You should use web.xml

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
<?xml version="1.0" encoding="UTF-8"?>
<web-app id="WebApp_ID" version="3.0"
xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd">
 <display-name>Training</display-name>
 <welcome-file-list>
  <welcome-file>index.jsp</welcome-file>
 </welcome-file-list>
 <!--- !!!!!!!!!! -->
 <error-page>
  <error-code>404</error-code>
  <location>/error/404.jsp</location>
 </error-page>
 <error-page>
  <exception-type>java.lang.Throwable</exception-type>
  <location>/error/exception.jsp</location>
 </error-page>
</web-app>

In this situation when resource will not be found (error 404) you server will show /error/404.jsp page where you could place (i.e.) like these :

1
Oops! Problems!

And all service information you could write to log or/and send to yourself by email (use JavaMail API i.e.)