Re: trim whitespace from jsps
Peter Horlock wrote:
I haven't measured file space reduction yet - however I am sure you
won't save that much, and you will
save more if you turn on gzip compression (but saving some space doesn't
hurt either, the smaller your pages are, the faster clients will receive
Concerning SEO, we are creating webpages based on data in our database
- the entire content is database based - the title tag, description tag,
well, really, all content.
Anyway, so the title tag is generated in a loop,
and as it is programmed using a JSTL for loop, the title is divided into
several lines. For some weird reason the G. Bot is to stupid or to lazy
to parse the entire tile tag => We need to find a way to write the
entire title (and the other meta tags too) in one single line.
The problem is that either Space Is Important, or Space Is Not
Important, you can't have it both ways.
In my opinion, this is a flaw with most template based languages (JSP,
PHP, Freemarker, Velocity, etc...)
One approach, which is still kind of ugly, but it works:
--%>Some thing that is repeated<%--
This allows you to keep some basic formatting while reducing whitespace.
The other alternative is to avoid using templates, and build up a DOM
Document programamtically, and then serialize the DOM as a text-stream.
This has quite a few disadvantages, but it is the "cleanest" output
(it ensures proper encoding and markup syntax).
Hope this helps,
Daniel Pitts' Tech Blog: <http://virtualinfinity.net/wordpress/>