We have been considering this also not too long ago.
It is possible to include a JSP using a custom HttpServletResponse so 
your app server's engine is used and there are standalone JSP engines 
but both these solutions seemed kludgy (capturing an include is not 
straightforward and adding a second JSP engine just to manipulate 
strings is overkill).
There are also numerous templating engines, we liked StringTemplate 
(http://www.stringtemplate.org/) for instance.

But in the end, we sticked to rolling out our own "engine". The code for 
it is as simple as this

     /**
      * @param fields - if param's key begins with _ it is replaced in 
the first pass, so it can contain ${} references to params replaced in 
second pass
      */
     private String fillInTemplate(String tmpl, Map<String, String> 
fields) {
         for (int pass = 1; pass <= 2; pass++) {
             for (String field : fields.keySet()) {
                 if (field.startsWith("_") || pass == 2) {
                     tmpl = tmpl.replace("${" + (field.startsWith("_") ? 
field.substring(1) : field) + "}", fields.get(field) != null ? 
fields.get(field) : "");
                 }
             }
         }
         return tmpl;
     }

HTH


------------------------------------------------------------------------------

_______________________________________________
Stripes-users mailing list
Stripes-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/stripes-users

Reply via email to