Cammarano Richard wrote:
> If an exception occurs in my controller servlet, what is the best way
> to handle the exception? Can I somehow direct the exception to my jsp
> error page? I've been following the Model2 discussions for some time
> now but don't remember this issue being raised. My current solution is
> to catch a particular exception, log it, and forward to a notification
> page with a message for the users. I figure that many of you have
> already encountered this and could offer some suggestions.
> Thanks.
>
This is pretty much what I've done in the past. I have a try..catch loop in my
controller servlet that catches any exceptions thrown by my action classes. (Of
course, I consider such things to be bugs, so that logfile gets attention).
One thing to consider using is the Servlet 2.2 mechanism for declaring <error-page>
directives in the "web.xml" file. You can direct particular types of errors to
particular JSP pages, which can then combine the logging action (in a scriptlet or
custom tag) with the display-to-the-user action. This way, you catch and log
exceptions in your JSP pages as well (perhaps from code in a scriptlet or custom
tag).
Craig McClanahan
===========================================================================
To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff JSP-INTEREST".
Some relevant FAQs on JSP/Servlets can be found at:
http://java.sun.com/products/jsp/faq.html
http://www.esperanto.org.nz/jsp/jspfaq.html
http://www.jguru.com/jguru/faq/faqpage.jsp?name=JSP
http://www.jguru.com/jguru/faq/faqpage.jsp?name=Servlets