You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Mott Leroy <mo...@acadaca.com> on 2006/02/03 22:59:48 UTC

jasper exception and root cause

Sorry, there was a thread about jsp errors, but i thought this was 
different enough to warrant a new thread.

I'm having trouble programatically retrieving the root cause of a JSP 
Exception. Basically, if a NullPointerException is thrown on a JSP page, 
I want to know that this exception was thrown and report it. I defined 
an error page in my web.xml:

    <error-page>
         <error-code>500</error-code>
         <location>/error_pages/error.jsp</location>
     </error-page>

Then I created the error.jsp page, with <%@ page isErrorPage="true" %>

Now, however, when i purposefully throw a NullPointerException from 
another page, my error.jsp seems unable to programatically access this 
stack trace.

The "exception" implicit variable on this page is a "JasperException", 
which surprises me because the JSP 2.0 Spec (1.4.3) says that the 
exception should be of type javax.servlet.error.exception or 
javax.servlet.jsp.jspException. Doesn't seem like either is the case.

The JasperException's stack trace isn't useful to report and there 
doesn't seem to be a "getRootCause" method on a JasperException like 
there is for a JspException.

How can I retrieve the root cause?

The default 500 error page provided by Tomcat prints out both the 
JasperException as well as the root cause, so it seems like this should 
be possible.

Any help is much appreciated. Thanks.

- Mott

[tomcat 5.0.28]

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: jasper exception and root cause

Posted by Mott Leroy <mo...@acadaca.com>.
Len Popp wrote:

> JasperException is a subclass of Exception, so you should be able to
> use the usual Exception methods on it. But it's not a
> NullPointerException. JasperException is what I get if I mess up the
> syntax in a JSP page. So, check for that.
> 
> --
> Len

Actually, JasperException extends from ServletException which contains a 
method for retrieving the root cause. So that's what I was looking for. 
My bad.

- Mott

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: jasper exception and root cause

Posted by Len Popp <le...@gmail.com>.
On 2/3/06, Mott Leroy <mo...@acadaca.com> wrote:
> Sorry, there was a thread about jsp errors, but i thought this was
> different enough to warrant a new thread.
>
> I'm having trouble programatically retrieving the root cause of a JSP
> Exception. Basically, if a NullPointerException is thrown on a JSP page,
> I want to know that this exception was thrown and report it. I defined
> an error page in my web.xml:
>
>     <error-page>
>          <error-code>500</error-code>
>          <location>/error_pages/error.jsp</location>
>      </error-page>
>
> Then I created the error.jsp page, with <%@ page isErrorPage="true" %>
>
> Now, however, when i purposefully throw a NullPointerException from
> another page, my error.jsp seems unable to programatically access this
> stack trace.
>
> The "exception" implicit variable on this page is a "JasperException",
> which surprises me because the JSP 2.0 Spec (1.4.3) says that the
> exception should be of type javax.servlet.error.exception or
> javax.servlet.jsp.jspException. Doesn't seem like either is the case.
>
> The JasperException's stack trace isn't useful to report and there
> doesn't seem to be a "getRootCause" method on a JasperException like
> there is for a JspException.
>
> How can I retrieve the root cause?
>
> The default 500 error page provided by Tomcat prints out both the
> JasperException as well as the root cause, so it seems like this should
> be possible.
>
> Any help is much appreciated. Thanks.
>
> - Mott
>
> [tomcat 5.0.28]
>

JasperException is a subclass of Exception, so you should be able to
use the usual Exception methods on it. But it's not a
NullPointerException. JasperException is what I get if I mess up the
syntax in a JSP page. So, check for that.

--
Len

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org