I am a newbie in JavaJSF. I want to create 1 errorpage for all my different exceptions. (checked)
I am using JSF 2.0.
I throw all the different exceptions from the DAO classes, to the controllers, and then to the bean classes.
Like Pradeep says, displaying a stacktrace in an error page isn't usually recommended. At best, it annoys the user, who won't be able to understand it. At worst, a knowledgeable hacker-type has just learned all sorts of useful information about the internal architecture of your system. Just put up a "user-friendly" message and provide a way for the user to continue on.
On the other hand, DON'T just swallow the stacktrace. Write it to a log file. And I mean a REAL log file, not "system.out/System.err". Most loggers have some sort of method like "log ("Error adding record", exception);" where you can pass the exception to the logger and it will log not only the primary stack trace, but the subsidiary stack traces as well.
An IDE is no substitute for an Intelligent Developer.
Mathias Van daele
Joined: May 29, 2010
Thanks for your answers.
Printing the exception stacktrace in an errorpage, is indeed not a good idea,
but I was just making a web application, for myself, to learn JSF.
Fist I was considering to catch all the exceptions in the bean methods, but this seems like a lot of work.
If I throw them again in the bean methods on the other hand, I don't know how to catch the content/stacktrace of the exception.
I guess there must be a simple solution, but I dont know how.
I’ve looked at a lot of different solutions, and in my humble opinion Aspose is the way to go. Here’s the link: http://aspose.com
subject: JSF 2.0 exception handling - Is it necessary to catch the exceptions in the Bean classes ?