title: Velocity Spring Bind
body: <p>I have a requirement to store a jsp in a database. I managed to store the html in the database and display using escapeHTML. The problem I had was with jsp tags. They never resolved.</p>
  
  <p>I am now using Velocity Templates instead. I am busy with a proof of concept and managed to get variable substitution and the use of if statements working using Velocity.evaluate. I now have a problem using spring tags for binding as I cant get the macros to resolve. Any ideas on what my problem could be?</p>
  
  <pre><code>    Velocity.init();
  
      VelocityContext context = new VelocityContext();
  
  
      String template="#springBind(\"command.firstname\") " +
      "   &lt;input type=\"text\" size=\"50\" maxlength=\"255\" id=\"userName\"  " +
      "       name=\"${status.expression}\"  " +
      "       value=\"${status.value}\"  " +
      "   &lt;div class=\"requiredexample\"&gt;  " +
      " e.g. username@domain.com  " +
      "   &lt;/div&gt;  " +
      "   &lt;div class=\"errors\"&gt;${status.errorMessage}&lt;/div&gt;  ";
  
  
      StringWriter writer = new StringWriter();
      Velocity.evaluate(context, writer, "TemplateName", template);
  
      System.out.println(writer);  
  </code></pre>