Java Tutorial - Java Script :
What Is a Template Engine?
If you have ever played the game Madlibs, then you should have a conceptual grasp of what a template engine does. A template is a document, in our case typically a Web page, with placeholders (spaces) for certain information. Template engines are typically deployed within the servlet container and used as part of the presentation layer of an enterprise application. The template engine combines the template with the information needed to fill in the spaces. For example, the line below represents a simple template:
Hello my name is ${name}. I live in ${state}.
If we give the line above to a template engine as a template with values of name=Jim and state=Tennessee , the template engine would create the document shown below as output:
Hello my name is Jim. I live in Tennessee .
In this case ${name} is used as the placeholder that is replaced with data. This capability is very useful for creating dynamic content for Web-based applications.
Template engines are not a part of the J2EE specification or architecture. However, template engines are a very useful component for creating Web applications, representing an alternative to JavaServer Pages.
