The .war is served from GlassFish v3. I am trying to include a javascript file from my jspx.
I used <script ...><jsp:text> </jsp:text></script>
and that retained the closing tag. I think this is ugly, so if anyone has a better answer I would definitely be interested.
Unfortunately, jspx is known to "minimize" empty elements. One way to prevent the minimization without adding a space to the rendered HTML is to insert a comment. For example:
<script ...><!-- keep open/close tags --></script>
It is still ugly, though.
A potentially cleaner solution would be to create a custom taglib that outputs correct HTML, e.g.:
<m:htmlScript type="text/javascript" src="/js/jquery-1.4.4.min.js"/>
producing:
<script type="text/javascript" src="/js/jquery-1.4.4.min.js">
Another alternative would be to encapsulate the tag in CDATA:
<![CDATA[<script type="text/javascript" src="/js/jquery-1.4.4.min.js"></script>]]>
I covered this topic in more detail here: How to produce valid HTML with JSPX? (not XHTML)
Yet another ugly solution:
<tag>${null}</tag>