I wrote a servlet to handle the exceptions occurring in my web app and mapped them in web.xml
<error-page>
<exception-type>java.lang.Exception</exception-type>
<location>/exceptionHandler</location>
</error-page>
Here is what I have done in the Exception Handling servlet service
method:
@Override
protected void service(HttpServletRequest req, HttpServletResponse arg1)
throws ServletException, IOException {
Object attribute = req.getAttribute("javax.servlet.error.exception");
if(attribute instanceof SocketException){
// don't do anything
}else{
super.service(req, arg1);
}
}.
Problem:
The above approach is not working and the stack trace is printing to the console. This occurs when the user requests something and then closes their browser.
Question:
How do I stop printing the stacktrace to the JBoss console whenever a SocketException
occurs?
Reason for doing this:
I want to avoid seeing all of the log's SocketException
s at the end of th day because I can't do anything with that information.