0
votes

I'm trying to use the @include_page macro from FreemarkerServlet - using Maven Freemarker framework with Freemarker version 2.3.31 and I can see the notes about this tag being now available in the source of it, but it still is not resolved/recognized in the actual template output.

For context:

  • Everything is fully configured and working as expected with pure ftl
  • We have a dependency on using JSP-only templates for a part of the output (while the main code base is using only .ftl templates)
  • The @include_page allows to include jsp pages into ftl
  • How I'm trying:
    • In WEB-INF/views directory, let's say there is a home.ftl
    • Add hello.jsp with <h2>Hello!</h1>
    • In home.ftl
<#assign....>
.
.
.
<div>
 <@include_page path="hello.jsp"/>
</div>
.
.
.

  • This results in an error that statement on the line with include_page was not found on null followed by instructional on using defaults or ifs

Does anyone know if there is some additional configuration needed to make use of it?

2

2 Answers

1
votes

The issue was that we needed to add the

model.put( FreemarkerServlet.KEY_INCLUDE, new IncludePage( request,
        response ) );

to the FreemarkerView model.

This is the post that actually solves the problem.

0
votes

To use JSP support (and include_page is part of it) you have to invoke the template with forwarding to an URL that's mapped to the FreemarkerServlet, instead of directly calling FreeMarker with its Java API. It's just how JSP works too (or have worked, originally). See https://freemarker.apache.org/docs/pgui_misc_servlet.html for details.