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.
Created attachment 16679 [details] Patch file generated against SVN on October 12th 2005 Patch contains modifications to ...jasper.compiler.Compiler.java and ...jasper.servlet.JspServletWrapper.java
Tim, this looks like a fantastic enhancement. Thank you for submitting it and all the associated information at http://www.tfenne.com/jasper/. I've committed it into HEAD, it'll be in 5.5.13.
Most people likely use development mode in production. This could lead to memory trouble :(
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.