• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Freemarker and include_page directive - Almost there I think

 
Ranch Hand
Posts: 17424
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi there,

I've been trying to get freemarker to be able to perform a include in the same way as a jsp page does. As of Freemarker 2.3.15 this possible according to the manual (extract below)

Including content from other web application resources

You can use the <@include_page path="..."/> custom directive provided by the FreemarkerServlet (since 2.3.15) to include the contents of another web application resource into the output; this is often useful to integrate output of JSP pages (living alongside the FreeMarker templates in the same web server) into the FreeMarker template output. Using:

<@include_page path="path/to/some.jsp"/>

is identical to using this tag in JSP:

<jsp:include page="path/to/some.jsp">



I noticed that jforum uses the 2.3.9 jar file so I have replace this with the 2.3.15 but if I try to use this directive I get a message telling me the directive can not be found:

on line 8, column 1 in default/header.htm include_page not found. The problematic instruction:



There is a note in the documentation that if the Application does not use freemarker.ext.servlet.FreemarkerServlet then this functionality is not available. My question is how do I get Jforum to use this? I have the src code from cvs in eclipse and I've tried a few things in the JForumBaseServlet but I can't seem to figure out how to get JForum to use this.

Any advice would be greatly appreciated!

Best regards

David




[originally posted on jforum.net by daverh]
 
Migrated From Jforum.net
Ranch Hand
Posts: 17424
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Don't know about freemarker and jsp, but I do know that jForum does use the servlet.

Instead, it creates a Freemarker TemplateConfig object in the JForumBaseServlet. Then uses this to get the FreeMarker template object in the Command object, process method. Which has it's process method called in the JForum.processCommand method.

Note, there may be a few other places that templates get processed or created via the TemplateConfig (like in the install servlet). So, you may need to search around a bit to make sure.

I wonder if you can add the right options to the TemplateConfig to get this to work?
[originally posted on jforum.net by monroe]
 
Migrated From Jforum.net
Ranch Hand
Posts: 17424
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Monroe

Thanks, I notice there are a couple of methods available for Configuration that look like they might work but I don't seem to be able to get them to work and I don't seem to be able to find any documentation to explain how to do it.

You mentione that JForum does use the servlet but I couldn't see where this is being set up?

I've posted a message on the freemarker site too so hopefully someone will get back to me on how to get this working from there

Best regards

David
[originally posted on jforum.net by daverh]
 
Migrated From Jforum.net
Ranch Hand
Posts: 17424
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Sigh... typo on my part... should be "does NOT use the servlet".... sorry.
[originally posted on jforum.net by monroe]
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic