Joe
Joe

Reputation: 11

Handling file not found on ftl page in Freemarker

How can we handle the file not found exception on fileName.ftl file? So many have explained handling it on the action servlets. But I am not using any action servlet to load the freemarker. So no other option and I have to find a way to handle it on the template file itself..!

Upvotes: 1

Views: 1205

Answers (1)

Chaquotay inactive
Chaquotay inactive

Reputation: 2232

If the FileNotFoundException occurs during a FTL <#import> or <#include> inside your "main" FTL template, then I think you can catch the exception with FTL's attempt-recover-construct (similar to Java's try-catch). But if your "main" template cannot be found, then something outside of FreeMarker (e.g. the servlet which invoked FreeMarker) has to deal with it.

Upvotes: 2

Related Questions