1

Im currently using the following to output to a servlet using StringTemplate:

(ST)page.render();

When I do this, StringTemplate prints warnings to Stderr; filling up log files with useless warnings is not ideal.

If I understand the documentation correctly, will the following fix this:

STWriter out = new MyCustomWriter(response.getWriter());
page.write((STWriter)out, (STErrorListener)myListener);

And on a side note, will doing this save having to build an entire page of strings in memory?

Jay
  • 19,649
  • 38
  • 121
  • 184

1 Answers1

2

I've put some time into digging through the javadoc and mucking around with the code, the following seems to suppress the errors completely:

page.write(new NoIndentWriter(response.getWriter()), new ErrorBuffer());

The ErrorBuffer simply collects all the warnings, which I can then ignore, or process if need be.

(I should post a separate question about if its possible to prevent this warning, but for now this works)

Jay
  • 19,649
  • 38
  • 121
  • 184