Loading
Free Marker Templete Engine

Java Quick Notes

Refresh Your Java - Before Java Interview

We are Agile, believe in less Documentation - Only Quick notes (Java Interview Questions) of Java/J2ee Read more....


Not Included Yet
Not Included Yet
Not Included Yet
Not Included Yet
Not Included Yet
Not Included Yet
Not Included Yet
Not Included Yet
Not Included Yet
Not Included Yet
Not Included Yet
Not Included Yet
Not Included Yet
Not Included Yet
Not Included Yet
Not Included Yet
Not Included Yet
Not Included Yet
Not Included Yet
Not Included Yet

Go to SiteMap

Q)  Free Marker Templete Engine ?


Ans)

import freemarker.template.*;
import java.util.*;
import java.io.*;

public class FreeMarkerExample {

    //Load the Templates only once
    static{
       /* Create and adjust the configuration */
        Configuration cfg = new Configuration();
        cfg.setDirectoryForTemplateLoading(
                new File("/store/templates"));

        cfg.setObjectWrapper(new DefaultObjectWrapper());
 
 }

    public static void main(String[] args) throws Exception {
        /* Get a template */
        Template temp = cfg.getTemplate("test.ftl");

        /* Create a data-model */
        Map root = new HashMap();
        root.put("user", "John Joe");
        Map latest = new HashMap();
        root.put("latestProduct", latest);
        latest.put("url", "test/yourTest.html");
        latest.put("name", "yourTest");

        /* Merge data-model with template */
        Writer out = new OutputStreamWriter(System.out);
        temp.process(root, out);
        out.flush();
    }



Back to top

------------------------- We hope you got necessary Info On -----------------------------------------

Free Marker Templete Engine


Free Marker Templete Engine

-------------------------------------------------------------------------------------------------------



Face Book
Request for a Mock Interview/Training

Get a PDF

Face Book
Same look (Read) on any device, this is Ads free