Wednesday, September 30, 2009

Mixing JSP 2.0 with GWT

I've just overcome a pesky litle problem between JSP 2.0 and GWT. I have my JSPs in xml format: <jsp:root ...>. You are likely aware that this is a bit aggressive about removing whitespace from the resulting html. This includes the transformation of empty body tags into bodyless tags. Ergo this
<div id="footer"></div>
becomes this
<div id="footer"/>

Now that second one was confusing firefox on my linux workstation. Likely on your platform as well. This is just like the old days when we fought with <script src="thefile.js" /> tags to make sure they keep their separate closing tag.

The solution is just to drop a comment into the previously empty body
<div id="footer"><![CDATA[<!-- -->]]></div>

Thank you Ramon, for pointing me down the path. It's been a long time away from servlet code. It should not have taken me as long as it did to remember this problem.

No comments: