I found the Tomcat param (web.xml):
<init-param>
<param-name>trimSpaces</param-name>
<param-value>true</param-value>
</init-param>
Which does a nice job - but for some reason it even removes spaces it
should NOT!!
The problem (and a few work arrounds a didn't like too much) is
described in more detail here:
http://raibledesigns.com/rd/entry/trim_spaces_in_your_jsp1
Any other ideas of how to fix this?
and so on doesn't really get you a clean html code...,
<c:out value=""/> and so on will clutter your jsp code...
Maybe this problem is fixed with Tomcat 6.x?
Any other solutions of how to get this done?
Thanks in advance,
Peter
--
Dave Miller
Java Web Hosting at:
http://www.cheap-jsp-hosting.com/
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
them...)
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.
Peter
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:
<%----%><c:forEach ...><%--
--%>Some thing that is repeated<%--
--%></c:forEach>
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.
--
Daniel Pitts' Tech Blog: <http://virtualinfinity.net/wordpress/>
The problem is that the words sometimes willbeputtogetherlikethisline...
>
> One approach, which is still kind of ugly, but it works:
>
> <%----%><c:forEach ...><%--
> --%>Some thing that is repeated<%--
> --%></c:forEach>
Do you want to say "fill the remaining space with jsp comments"?
Not a bad idea. Will try this on Monday.
Thanks,
Peter
So in conclusion, it's not that much, yet it's still something,
whether you are sending compressed pages or not.
For a big website like ours, this will save a few GBs of traffic, and
every page will load just a tiny bit faster for every single client -
all this by just adding 4 extra lines to your tomcat's web.xml.
However, turning on html compression will reduce file size by 70%!
Peter