Hi, all.
I'm finding that the JSP errorPage directive has a serious flaw.
Perhaps others out there have run into this and been as frustrated as I am
and hopefully come up with some solution...? The flaw is that, if the
response has already been committed, then the error page is just plopped
into the response where the error occurred - it has no way that I see of
generating a fresh response with just the error page content. Then the
problem is that, depending on where the original page died, the error page
content may not get displayed if it's caught inside some HTML tag where
the browser can't figure out how to render it.
Just as an example of this which I've seen, say you have a select
dropdown list populated from some List request attribute, so you output
"<select>" and then go to iterate through the List. Now, say the List is
null, and a NullPointerException is thrown, the errorPage content gets put
into the response right after the "<select>" tag and the browser doesn't
display it. (You can see it if you do View -> Source, but this obviously
defeats the purpose.)
This is quite annoying, and I'm amazed that this mechanism still
hasn't been improved. I searched for solutions to this, but the only
thing I could really find was using another framework like Velocity which
buffers the whole response and therefore can generate a completely
different one if an exception occurs at any step of the way.
Unfortunately, learning another framework just isn't in the cards.
Does anyone know of a way, besides maybe making the buffer size
really huge, to get around this problem? Would a Filter on the response
help with this? How would something like that work? (Never written/used
a Filter before)
Thanks!
-Jeff