The JasperException that is thrown whenever an exception is thrown either directly on a JSP or by code
invoked directly or indirectly from the JSP only ever contains the line number of the line in the
generated java servlet file. This means that developers have to trawl through the Tomcat working
directory, dig up the generated java file, then compare the generated line against their JSP to figure out
where the error originated from.
Several other containers, WebLogic and Resin to mention but two, provide more information; crucially
the line number in the JSP and in WebLogic's case a fragment of the JSP showing the error in context.
I have assembled a patch (which I will attach here) that provides similar functionality in Tomcat. The
diff is against SVN as of the date of submitting this bug. The full modified source files are available for
download at the URL attached to this bug, should the patch be out of date by the time it is processed.
I find this is a huge productivity booster for me, and my post to the Tomcat user mailing list elicited
replies asking for the source code *now*. I hope this can find it's way into the next build(s) of Tomcat.
I've tested it against 5.5.9 and 5.5.12, but not the 5.0 releases.

The new line numbering information is helpful but it looks like post 5.5.13,
after this change has gone in, the root cause exception is wrapped in an
additional layer, making it difficult to catch with settings in the web.xml like
<error-page>
<exception-type>javax.persistence.EntityNotFoundException</exception-type>
<location>/errors/404.jsp</location>
</error-page>
That config works in 5.5.12 and earlier, but with 5.5.13+ with development mode,
the exception appears to be wrapped one layer thicker (once in the generated
tags code, and once in the ServletWrapper) so that the error-page behavior breaks.

This is ASF Bugzilla: the Apache Software Foundation bug system. In case
of problems with the functioning of ASF Bugzilla, please contact
bugzilla-admin@apache.org.
Please Note: this e-mail address is only for reporting problems
with ASF Bugzilla. Mail about any other subject will be silently
ignored.