"Catch all" exception in a servlet
I have a servlet that is deployed on WebLogic 8.1. At one point I am initializing a XSLT processor that is throwing an error.
I don't know what error as the Servlet implementation (AIX machine, JDK 1.4) is catching it and showing me "Page cannot be displayed"
Is there any configuration that tells a web application to catch all the errors?
# 1
Hi,
Are you looking at the server logs to see what the error was?
If you allow the servlet container to catch the exception, it should be logging some type of message to let you know what is going on. This is how the Glassfish appserver works ( http://glassfish.dev.java.net ).
If you don't see a message in the log, you can wrap your servlet code with a try catch block and log the exception, for example:
try {
// YOUR CODE
} catch (Exception e) {
e.printStackTrace();
}
If you are still having problems, you may want to deploy the application on the Glassfish application server, which would show the error in the log automatically.
To further simplify your development, you can use the Netbeans IDE ( http://netbeans.org ) to develop your servlet. It has code completion and syntax highlighting that helps identify errors quickly.
Hope this helps...
Thanks - Mark