Freemaker example

This example demonstrates how to use Freemarker templating engine to produce web pages via Jersey viewable support. Both explicit and implicit viewable patterns are demonstrated using the FreemarkerResource resource class.

Content

See FreemarkerResource for details on how to use jersey-freemaker module for generating web pages. The explicit viewable generating sub-resource method in the FreemarkerResource class is quite self-descriptive. Since Jersey implicit viewables feature is turned on in the Main class, an implicit viewable generating resource method will be automatically generated by Jersey runtime for the FreemarkerResource class and mapped to GET requests in addition.

Notice: If you want to use freemarker in your project, don't forget to set "com.sun.jersey.freemarker.templateBasePath" init param, which will be pointing to the base directory where your templates are stored (The application Main class as well as the FreemarkerTest class does exactly that to make the hello.ftl template available for Jersey runtime).

Running the Example

Run the example as follows:

mvn clean compile exec:java

This deploys this example using Grizzly

You can then check the output produced by Freemarker at the following URIs: