velocity-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Shinobu Kawai <shin...@ieee.org>
Subject Re: Effectively overriding the 'error()' function in VelocityServlet?
Date Fri, 20 Aug 2004 00:48:32 GMT

Hi Peter,

> I find that any html written to the HttpServletResponse from the 'error()'
> method if resulting from an exception from a template method call gets
> appended after the portion of the template that was parsed before the
> exception occurs.  For example if I call a method half way through my
> template that throws an exception, the first half of the template will be
> merged into the response, and then any html from the 'error()' method.  This
> makes it seemingly impossible to present the user a nice error page.  I
> assume this happens because the data is written immediately to the response
> as it is merged.
>  
>  I have tried clearing the buffer of the response in 'error()', but it does
> not work as it claims the response has already been committed, which makes
> sense as the merge has sent the partially merged template to the client
> already.  Suggestions?
I would say, create your own buffered HttpServletResponse (a wrapper, of
course), override for "*.vm" using a filter, and do your stuff in error().

Best regards,
-- Shinobu Kawai

--
Shinobu Kawai <shinobu@ieee.org, shinobu@computer.org>




---------------------------------------------------------------------
To unsubscribe, e-mail: velocity-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: velocity-user-help@jakarta.apache.org


Mime
View raw message