Reputation: 57928
is there a good way to trim whitespaces generated by JSPs without resorting to the following techniques:
Id like to know if anyone knows a better way to selectively trim spaces in JSPs
edit: what i do now is put all my tags on one like like this:
<c:forEach var="date" items="${model.list}"><%--
--%><c:set var="dateStr"><ct:dateFormat date="${date.startDate}"/></c:set><%--
--%><option value="${dateStr}">${dateStr}</option><%--
--%></c:forEach>
Upvotes: 4
Views: 4182
Reputation: 21680
Try: http://coldjava.hypermart.net/servlets/trimflt.htm Just implemented it myself as servlet filter, works a charm.
Another option is: htmlcompressor (google it, I can only provide 1 link atm...)
The taglib of htmlcopressor allows you to use a wrapper, also has compressors for css and js.
Upvotes: 0
Reputation: 11
check out Trim filter from JSOS: http://www.servletsuite.com/servlets/trimflt.htm
Upvotes: 0
Reputation: 1108672
eating spaces where you want them
Can you give an example? I really can't imagine of such a need.
Do you mean inside textareas? Inside HTML <pre>
elements? Inside CSS white-space:pre
styled elements? The Tomcat's trimSpaces
setting should nicely take them into account.
Or do you mean spaces for layout? Well, they really doesn't belong there. Consider replacing by CSS margin/padding properties and keep the trimSpaces
setting.
Upvotes: 2
Reputation: 162771
You're dealing with a least-of-all-evils choice here. I would go with the jasper trimSpaces directive and if you have whitespace that is significant in your layout, you can strategically insert whitespace like this:
<c:out value=" " />
or like this:
${ }
Other options for trimming whitespace that haven't been mentioned in your post are:
Upvotes: 2