Re: Exception handling in Spring-MVC/FreeMarker web applications

Guo Du <[email protected]>
Newsgroups gmane.comp.web.freemarker.user
Message-ID <[email protected]>
On Wed, Oct 21, 2009 at 9:25 PM,  <[email protected]> wrote:
> Maybe... but if the handler rethrows the exception, what catches it in the
> SpringMVC environment? How would my app know to force a 500 error response
> back to the client? I'm trying to get my brain round that. I think I need
> to experiment a bit.
You don't know there would be exception or not unless the template
finish rendering. By default, freemarker will write the rendering
result to http response outputstream in runtime.

If you want send 500 error if there are exception during the
rendering, you may let freemarker render to a temp outputstream. Once
the render finished without exception, then you write the temp
outputstream to your http response outputstrea. If there are
exceptions during rendering, you may handle with 500 error.

-Guo

------------------------------------------------------------------------------
Come build with us! The BlackBerry(R) Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay 
ahead of the curve. Join us from November 9 - 12, 2009. Register now!
http://p.sf.net/sfu/devconference
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.