Re: Exception handling in Spring-MVC/FreeMarker web applications
"Newman, John W" <[email protected]>
| Newsgroups | gmane.comp.web.freemarker.user |
|---|---|
| Message-ID | <D688C4D318A63D4290AA94A33E06F7D2027BC1AEFA@msxmbxnsprd14.acct.upmchs.net> |
Hi - Take a look at configuration.setTemplateExceptionHandler(TemplateExceptionHandler.RETHROW_HANDLER); RETHROW_HANDLER may not be what you want ... I forget what each does, there are a few different options. But that's the setting you're after -----Original Message----- From: [email protected] [mailto:[email protected]] Sent: Wednesday, October 21, 2009 2:36 PM To: [email protected] Subject: [FreeMarker-user] Exception handling in Spring-MVC/FreeMarker web applications While developing a web application using Spring and FreeMarker I've found that exceptions during template processing (caused, for example, by keys referenced in the template but missing from the model map) result in stack traces being thrown out all the way to the client browser. One of the main reasons for migrating away from JSPs (apart from them being inefficient, dangerous, difficult to work with, nightmarish to debug, etc., etc., etc.) is that JSPs have a nasty tendency to send stack traces to the browser. I was really hoping FreeMarker wouldn't do the same thing. The problem appears to be that FM sends the stack trace to the same output stream that the processed output would normally be sent to, and in a web environment that's going to be the response output stream. I need to make sure that one way or another template processing exceptions are caught in a way that lets the application (or the View) throw out a response.sendError() call (ideally with a configurable error code, but a hard-coded '500' error would be acceptable) and log the error trace in the server log. At the very least I need a way to make certain that the client doesn't see a stack trace, ever, under any circumstances. So the question is, does FreeMarker (or the Spring FreeMarkerConfigurer or FreeMarkerView) have any kind of configuration setting to cover for this? I could probably create a proprietary View class that catches the exception, but I'd rather stick with the out-of-the-packet code if I can. ------------------------------------------------------------------------------ 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 _______________________________________________ FreeMarker-user mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/freemarker-user ------------------------------------------------------------------------------ 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