The exception is not related to the template. Some server are really picky about the handling of the output stream, and I guess GlassFish is one of them.
When you call renderToStream, Chart FX gets the output stream to push the image, but If you have blank line at the end JSP file for example, the compiled JSP will try to output that blank line to the output stream as well, and since ChartFX took it, you get the exception. Some serves will just throw a warning, but you'll get the image.
There are 2 things to try:
1) remove all extra lines and characters, ie:
<%com.softwarefx.chartfx.gauge.HorizontalGauge.initWeb(pageContext,request,response);
com.softwarefx.chartfx.gauge.HorizontalGauge gauge = new com.softwarefx.chartfx.gauge.HorizontalGauge();
gauge.importGauge(com.softwarefx.chartfx.gauge.FileFormat.XML, application.getRealPath("smallChart.hgfx"));
gauge.renderToStream();%>
Be sure the file ends at %>, or
2) Call gauge.renderToControl(), which will create a image in the temp folder and will return the image tag to the browser.
I'll take a look to the samples on Glasfish, and I'll adjust them accordingly