Pete Serafin wrote:
>
> Is it possible for the JSP error directive to capture any other type of
> exceptions other than just javax.servlet.jsp.JspException.  Im trying
> to catch any types of exceptions in my JSPs including Jasper and plain
> Exceptions, but Im not sure if this is possible.  Has anyone does this
> without using scriplet coding?

Based on the J2EE spec, JSPException is what you get. By definition, a
JSPException is what a "JSP Engine" must throw if it finds an error. Also
by definition, any JSP Tags - including the Struts tags - must throw
JSPException.

That being said, there is a way to get at the actual error - one of the
JSPException methods is:

     public java.lang.Throwable getRootCause()

which allows you to find the actual exception.

So the way to have the "errorpage" directive be used to handle a variety of
different Exception's is to code an "errorpage.jsp" that inspects
exception.getRootCause() and makes processing decisions based on it.

One Struts-oriented solution may be to create an ExceptionAction and design
an errorpage.jsp to automatically forward you there - carrying the
exception as a parameter in some way. Then if the errorpage machinery kicks
in, you may be able to have an Action class control the processing. This
would allow you to avoid in-line scripting and tightly control processing.

Anyone see any problems with this approach? Anyone done anything like this?


FWIW -
Kevin


Here are a couple references:


     
http://developer.java.sun.com/developer/onlineTraining/JSPIntro/exercises/ErrorHandling/


     http://java.sun.com/j2ee/sdk_1.3/techdocs/api/javax/servlet/jsp/JspException.html






---------------------------------------------------------------------------
This e-mail message (including attachments, if any) is intended for the use
of the individual or entity to which it is addressed and may contain
information that is privileged, proprietary , confidential and exempt from
disclosure.  If you are not the intended recipient, you are notified that
any dissemination, distribution or copying of this communication is
strictly prohibited.  If you have received this communication in error,
please notify the sender and erase this e-mail message immediately.
---------------------------------------------------------------------------


--
To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>

Reply via email to