Skip to main content
Article thumbnail
Location of Repository

Html template system using java annotations

By Peter Speck


The problems that motivate this project are to (1) solve the lack of separation between html templates and java code when using existing template systems (e.g. embedded language or macros), to (2) solve the lack of scoped declaration of macros and java variables inside template loops, and (3) to solve the lack of validation of template macro definitions at compile time to help finding bugs before the web applications are deployed. Annotations are used as metadata format for specification of the dynamic parts of the html template and 74 annotations are designed for the template system. The html templates don't contain embedded macros and are fully valid html files without any special tags or attributes, and well suited for editing in visual editors. An annotation-based template compiler and runtime are implemented and tested. Strict type checking is performed by the template compiler when it processes the annotations. The compiler generates java source files which enables IDEs to show usages of template macro implementations, i.e. servlet methods and fields. The system provides template looping constructs by using Iterators and automatically instantiating the appropriate inner class for each object returned by the iterator. The inner classes provide scoping for temporary variables used by the loops to avoid polluting the global servlet scope with temporary variables. Tests of annotations as specification format show that the new system provides very concise specifications for common web implementation design patterns and makes servlets easier to maintain

Topics: java, annotations, html, templates
Year: 2007
OAI identifier:

Suggested articles


  1. (1998). AntiPatterns. Refactoring Software, Architectures, and Projects in Crisis.
  2. (1978). Characteristics of application software maintenance. doi
  3. (2006). Demystifying maintainability. doi
  4. (1995). Design Patterns. doi
  5. (2004). Java 5.0 Tiger. A Developer’s NotebookTM.
  6. (2000). Reusability and maintainability metrics for object-oriented software. doi
  7. (1997). Software change through design maintenance. doi
  8. (1993). Software complexity and maintenance costs. doi
  9. (1979). The Art of Software Testing. doi
  10. (2006). The JavaTM Programming Language, Fourth Edition.
  11. (2006). Tool support for randomized unit testing. doi

To submit an update or takedown request for this paper, please submit an Update/Correction/Removal Request.