Note to self: use trimDirectiveWhitespaces in JSPs after switching to Tomcat 6

So JSPs have the annoying property of preserving all whitespace from the source JSP file and outputting it. As soon as your JSP gets at all complex, with conditional logic, variables being set, and so on, you’ll find your HTML source output gets filled more and more with blank lines.

JSP 2.1 to the rescue! Now there’s a handy page directive you can put at the top of your JSP file:

<%@ page trimDirectiveWhitespaces="true" %>

The only problem is that Tomcat 5.5 doesn’t support it, and that’s what we’re using right now. I guess Tomcat 6 is still in development.

So this blog posting is just to remind myself to use it in the future when it becomes available to us.

And yes, I know it has been forever and forever since I last posted.

Comments are closed.