You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by bs...@arsdigita.com on 2000/09/18 15:51:55 UTC

JSP errorPage: forwarding vs. including

Question about org.apache.jasper.runtime.PageContextImpl, line 381
(Tomcat 3.1 release):

Why do we forward rather than include errorPageUrl in method
handlePageException()?  Although I'm sure there's a good reason for
doing so, forwarding to the error page prevents a useful error message
from being displayed if there was a previous call to
pageContext.include  or a <jsp:include> before the Exception is thrown.
You'll get an IllegalStateException "Cannot forward as OutputStream or
Writer has already been obtained" instead.

Changing the line to "include(errorPageURL)" works beautifully.

-- Bill


Re: JSP errorPage: forwarding vs. including

Posted by Danno Ferrin <sh...@earthlink.net>.
Forwarding is defined as part of the means to handle it, and the error
you are encountering is an acceptable and expected part of JSP.  page 47
of the JSP 1.1 spec has what I think you are looking for (it follows my
sig)

--Danno

errorPage 

Defines a URL to a resource to which any Java programming language
Throwable object(s) thrown but not caught by the page
implementation are forwarded to for error processing.

[snip]

Note: if autoFlush=true then if the contents of the initial
JspWriter has been flushed to the ServletResponse output
stream then any subsequent attempt to dispatch an uncaught exception
from the offending page to an errorPage may fail.

bschneid@arsdigita.com wrote:
> 
> Question about org.apache.jasper.runtime.PageContextImpl, line 381
> (Tomcat 3.1 release):
> 
> Why do we forward rather than include errorPageUrl in method
> handlePageException()?  Although I'm sure there's a good reason for
> doing so, forwarding to the error page prevents a useful error message
> from being displayed if there was a previous call to
> pageContext.include  or a <jsp:include> before the Exception is thrown.
> You'll get an IllegalStateException "Cannot forward as OutputStream or
> Writer has already been obtained" instead.
> 
> Changing the line to "include(errorPageURL)" works beautifully.
> 
> -- Bill
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: tomcat-dev-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: tomcat-dev-help@jakarta.apache.org