tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From manuel aldana <>
Subject 500 HTTP-status forwarding broken (JSP rendering + Exception occurence)
Date Thu, 05 Apr 2012 15:42:47 GMT
Inside web.xml I defined <error-page>500..., so 500-status is resolving 
to JSP error pages. I get inconsistent behaviour when an Exception 
occurs during JSP rendering.

1) JSP syntax error (e.g. broken XML):
-> 500 status is set correctly
-> forward to jsp-error page is done correctly and 500 returned to browser

2) JSP runtime error:
-> 200 status
-> i.e. broken 500-forward to error.jsp
-> I get broken HTML inside browser

Second case is quite dangerous because we didn't see anything inside 
logs and 200 status was presented though we had production bug. Just 
accidently looking at catalina.log (stdout logging of all exception) 
covered this.

I checked source-code (6.0.35):

if (isCommitted())

My assumption:
- In 1st case 500 forward + status setting works fine, because JSP 
rendering breaks from beginning and no content is flushed to output-buffer
- In 2nd case "some" of jsp is rendered and written to output-buffer and 
resetting-status is prohibited (see isCommitted() check)
=> i.e. there is no way forwarding to 500 status when error occurred 
during runtime of JSP rendering

I guess this is a bug (want to backup first before creating trace-ticket)?

Do you know a workaround for this? Currently I have workaround to have a 
special Filter checking for Exceptions and including 200 status. The bad 
thing is that still browser/users get returned 200 OK status, though 
error occurred , because resetting status isn't allowed.

Thanks for support.

  manuel aldana
  mail: |

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message