This is one of the biggest reasons why
you should have little or no logic in JSPs.
In
Tomcat - and you did ask in the Tomcat forum - the Jasper compiler converts the JSP into a servlet coded in
Java. The Java equivalent of the JSP is written to the Tomcat work directory, where it is compiled into a java class. Displayed error line numbers are usually going to be based on the servlet's java source code, not on the original JSP.
In addition to the mere fact that you have to use indirection just to find the offending line number, reverse-engineering that line back to a JSP line number can be quite difficult, since aside from being obscured by housekeeping code, a certain amount of relocation takes place as well.
Moral of story: keep your Model and Controller code out of your View.
The secret of how to be miserable is to constantly expect things are going to happen the way that they are "supposed" to happen.
You can have faith, which carries the understanding that you may be disappointed. Then there's being a willfully-blind idiot, which virtually guarantees it.