tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Andreas Junghans" <Andreas.Jungh...@fh-karlsruhe.de>
Subject [Q+Patch] Error page behaviour in TC 3.x and 4.0.1
Date Tue, 30 Oct 2001 11:54:15 GMT
Hi there,

we're having the following problem: We have an error page in our web app to
display and log all errors, no matter where they occur. We started
develpment with Tomcat 3.2.1, and all went as expected. However, Tomcat
4.0.1 suppresses the error page when parts of the JSP have already been
flushed.

I've looked at the source and found that in
org/apache/catalina/valves/ErrorDispatcherValve.java the error page is
invoked using RequestDispatcher.forward(). This only works when no output
has been flushed up to the occurence of the exception. In Tomcat 3.2.1
(don't know about the other 3.x versions) however, the output of the error
page can appear in the middle of a half-flushed JSP.

I've consulted the spec about that, and it says (jsp-1_2-fcs-spec.pdf on
page 38):

"Any uncaught exceptions thrown in the body of the JSP page implementation
class result in the forwarding of the client request and uncaught exception
to the
errorPage URL specified by the JSP page (or the implementation default
behavior,
if none is specified)."

However, I don't think "forwarding" in this case is really meant literally
regarding the RequestDispatcher interface - if that was the case, there
should be some additional explanation what to do if forwarding fails. IMHO,
allowing the error page's output to appear after some flushed JSP output
makes more sense:

1. There is a visual indication of an exception that occured in the middle
of a JSP.
2. The error page can be used as a central place for error handling (for
example, we're logging to a database table there).
3. I can't think of any reasons that really make forward semantics
desirable.

Of course it would be nice to have the original page completely replaced by
the error page, but when some bits are already flushed, you cannot take them
back. So why not append the error page instead of just cutting off the rest
of the JSP? OK, there is a log entry about failed delivery of the error
page, but the user doesn't see that. A workaround is to increase the buffer
size so nothing get's flushed until the page is compete, but this is not
acceptable in many cases (e.g. when loading large tables constructed from a
database).

So what do you think? Any objections to changing RequestDispatcher.forward()
to RequestDispatcher.include() (see proposed patch attached to this
message)?

Best regards

---------------------------------------------------------------------------

Dipl.-Inform.(FH) Andreas Junghans
Steinbeis-Transferzentrum Industrielle Datenverarbeitung und Automation
Moltkestrasse 30 - 76133 Karlsruhe
Fon.:  +49-721-925-1485  ---  Fax:  +49-721-925-1488
email: Andreas.Junghans@FH-Karlsruhe.de (privat: Bammus@aol.com)
---------------------------------------------------------------------------


Mime
View raw message