TINI-Mixer 0.5

TINI-Mixer (source, doc, jar, everything) is a helper-class that is easy to use for Servlet programmers in the TINI-environment that enable a complete separation of Servlet- and HTML-code. Licence: GNU GPL.

Tiny InterNet Interface (TINI) is a platform developed by Dallas Semiconductor to provide developers with a simple, flexible, and costeffective means to design a wide variety of hardware devices able to connect directly to different types of networks.

TINI-Mixer is developed to suit the TINI-environment, which is a JAVA 1.18 implementation, but there are some limitations such as no support for AWT. The memory footprint of TINI's Java Virtual Machine (JVM) is less than 40 KBytes. More information about TINI can be found here.

Example  Template Code Result
Non repeated HTML Java HTML
Repeated HTML Java HTML
Combined HTML Java HTML
Multiple repeated HTML Java HTML
Adding HTML HTML1
HTML2
Java HTML

TINI-Mixer does not use any new language and is very efficient. The template HTML-document is valid HTML that has two types of markers. Context-markers are markers, in the form of a HTML-comment, that are placed around parts of HTML-code that should be repeated:

<!---xxx--->
<tr>
  <td>
    ---name---
  </td>
  <td>
    <a href="mailto:---email---">---email---</a>
  </td>
</tr>
<!---xxx--->

Variable-markers are markers that should be substituted for values:

<p>
  My name is ---name--- and my email is <a href="mailto:---email---">---email---</a>.
</p>

For efficiency use TINI-Mixer in a Servlet like this:

Define a class-variable that holds a template HTML-document:

private static String htmlTemplate = null;

In method init, load content from a template HTML-file into this class-variable:

if (htmlTemplate == null) {
   htmlTemplate = Mixer.getContent(new File(getServletContext().getRealPath("x.html")));
}

In metod doGet and/or doPost:

Mixer m = new Mixer(htmlTemplate);
m.add("---email---", "pierre@dsv.su.se");
...
response.setContentType("text/html");
PrintWriter pw = response.getWriter();
pw.println(m.getMix());

Accordingly, costly file operations only take place during initialization of the Servlet. 

TINI-Mixer also adds functionality to mix different parts of different HTML-documents. This is done by preloading any number of template HTML-documents in the init-method and then selecting different parts of the template HTML-documents to build a new HTML-document. The resulting document can in turn be used as a template for further processing.

Please report bugs here.


Updated 2003-10-07 by Pierre A. I. Wijkman.

Valid XHTML 1.1 Valid CSS