Better Templates for Everyone

"Because web sites should be compiled!"


Better Templates for Everyone were designed to make it easy to maintain a web site. Using dynamic pages for everything is overkill. You might desire to give many of your pages a fresh look every once in a while, but from day to day, the contents of the pages stay the same. Better Templates for Everyone can be used to make updating static web pages easier while using the same process with dynamic web pages. Updating static pages can be done on virtually any web server and creating dynamic pages with bte can be accomplished through servlets.

Templates, however, are not limited to web pages. It would be possible to use them as a preprocessor for any programming language, or even use a implementation that generates them dynamically.


  1. Hello World
  2. Using Templates
  3. Suppressing Output
  4. Multiple Templates
  5. Defaults
  6. Error Handling
  7. Optional Sections
  8. Multiple Levels
  9. Navigation Bars
  10. Other File Types
  11. Branching: selecting and choosing using ones

Better Template Engine

A reference implementation of Better Templates for Everyone. It is written in Java and has been tested on both Windows and Linux. It is very fast and can compile large sites in seconds.


Download and install the Java2 Runtime Environment (JRE) from if you do not already have it installed.

Download the latest version of BTE including source code(Executable Jar - 129k)

Static Pages

To compile your website, just invoke the engine with your files as arguments using either of the following command lines:
java -jar bte.jar myfile.bte
java -classpath bte.jar com.Ostermiller.bte.Compiler myfile.bte
Alternatly, you may double click on the jar file or use no command line arguments to start a GUI that allows you to pick files to be compiled.

Dynamic Pages

Your servlet can create a BTE document, compile it, and return the result. This is a very flexible model, as your presentation layer is in template files, your logic layer is contained in the servlet, and the servlet could access your data from a database. In this manner BTE is alternative to Java Server Pages (JSP). Here is a simple example of a servlet that uses BTE:

import javax.servlet.*;
import javax.servlet.http.*;
import com.Ostermiller.bte.*;

public class xxxx extends HttpServlet { 

    protected com.Ostermiller.bte.Compiler compiler = new com.Ostermiller.bte.Compiler();
    public void doGet (HttpServletRequest request, HttpServletResponse response)
        throws ServletException, IOException {
        StringBuffer bte = new StringBuffer();
        bte.append("<%bte.doc super='' %>\n");
        bte.append("<%bte.tpl name=pageTitle %>Hello World!"<%/bte.tpl%>\n");
        bte.append("<%bte.tpl name=pageContent %>");
        bte.append("Say hello to the world.");
        Reader in = new StringReader(bte.toString());
        try {
            compiler.compile(in, response.getWriter()); 
        } catch (CompileException x){ 
            throw new ServletException("Error compiling BTE document: " + x.getMessage());  

A special exception to the GPL is made for servlets. Any servlet (java class used for serving web pages extending javax.servlet.Servlet) that uses only the com.Ostermiller.bte.Compiler() constructor and the com.Ostermiller.bte.Compiler.compiler(Reader, PrintWriter) methods of the com.Ostermiller.bte package shall be considered a separate program. Therefore, such a servlet may be distributed under any license, not just a GPL compatible license.

Version History

BTE 1.5 (Executable Jar - 129k)

BTE 1.4 (Executable Jar - 98k)

BTE 1.3 (Executable Jar - 96k)

BTE 1.2 (Executable Jar - 95k)

BTE 1.1 (Executable Jar - 95k)

BTE 1.0 (Executable Jar - 78k)


Copyright (c) 2000-2004 by Stephen Ostermiller

This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. (site index)