> I've used a Filter to strip out redundant whitespace from text/html > output. I wrapped the ServletResponse so that a custom > ServletOutputStream filters out empty and recurring linefeeds. Works > pretty well.
One downside to this approach is that the filter is being called for every request which may cause you a performance problem down the line.
A better approach would be a flag that the jasper compiler could locate to automatically strip redundant/duplicated C/Rs and TABs from the source when compiling so that statements like this:
out.write("\r\n\t\t\t\t<td ");become
out.write("<td ");eg
<% // <NOWHITESPACE> %>
\t\t\t\t<td <%=bgColor%>width="10" valign="top"><input type="checkbox" name="id" value="<%=String.valueOf(ff.getEncodedRef())%>"></td>\r
\t\t\t\t<td <%=bgColor%> width="18" valign="middle"><a href="<%=gotoURL%>"><%=icon%></a></td>\r
<% // </NOWHITESPACE> %>
becomes
<td <%=bgColor%>width="10" valign="top"><input type="checkbox" name="id" value="<%=String.valueOf(ff.getEncodedRef())%>"></td><td <%=bgColor%> width="18" valign="middle"><a href="<%=gotoURL%>"><%=icon%></a></td>
prior to compilation.
In fact this is the approach that I'm going to take. I'm going to write a source file pre-processor (maybe even as part of the Ant web-app build process) which will remove all redundant whitespace from the source file prior to compilation. It will only be used on a COPY of the orginal source files (prior to deployment)
Note that sometimes you need the whitespace - perhaps in javascript sections of the JSP page which is why you need to be able to switch on/off the whitespace removal.
If the jasper compiler could do this automatically then that would be great. On average you can see a 10% reduction in file size. We also use mod_deflate with Apache to reduce the data transmission costs even further.
John Sidney-Woollett
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
