A really simple JSP compiler that allows you to use JSP's for all templating not just web pages.

Based on GNUJsp.

Use JSP templates for generating emails, source code, files and other random things. Instead of usinga different a templating style each time, leverage JSP style templating in non-web environment.

For people who like their errors at compile time (scriptlets are good!), not runtime (JSTL is bad!).

Released under GPL.


  1. Create a bean with the data you want to present in it. (optional) public class CustomerOrder { private String name; private List itemsOrdered; public void setName(String name) { this.name = name; } public String getName() { return name; } public List getItemsOrdered() { return itemsOrdered; } public void setItemsOrdered(List itemsOrdered) { this.itemsOrdered = itemsOrdered; } }
  2. Create a JSP that extends it. (or just create a plain JSP) <%@ page extends="com.sample.CustomerOrder" %> Hi <%= getName() %>, Items you ordered: <% for (int i = 0; i < getItemsOrdered().size(); i++) { String itemOrdered = (String) getItemsOrdered().get(i); %> - <%= itemOrdered %> <% } %> Regards, Sample Company.
  3. Generate the Java source for the JSP using the JspTem ant task <taskdef name="jsptem" classname="org.tuckey.jsptem.JspTemAntTask" classpath="classes"> <classpath refid="common.classpath" /> </taskdef> <jsptem srcdir="src" destdir="src" listfiles="true"/>
  4. Compile the your source as normal source using ant (or your IDE).
  5. Use it in your code... GeneratedCustomerOrder customerOrderEmail = new GeneratedCustomerOrder(); List items = new ArrayList(); items.add("French Stick"); items.add("Apple"); customerOrderEmail.setItemsOrdered(items); customerOrderEmail.setName("Bob"); // to a file customerOrderEmail.writeToFile(myFile); // to a string String orderEmail = customerOrderEmail.writeToString(); // to a stream customerOrderEmail.writeToStream(myStream);