when tag in foreach inserts space character to rendered page
665045Nov 17 2010 — edited Nov 18 2010Hi,
It seem like a small issue, but it really messes up my webpage when doing something like this:
The following JSP page:
<%@ taglib uri='http://java.sun.com/jsp/jstl/core' prefix='c'%>
<html>
<body>
<%
String[] sA = {"a","b","c","d"};
pageContext.setAttribute("sA", sA);
%>
<c:forEach var="s" items="${sA}" varStatus="status">
<c:choose>
<c:when test="${s == 'a'}">
<c:out value="${sA[0]}"/>
</c:when>
<c:when test="${s == 'b'}">
<c:out value="${sA[1]}"/>
</c:when>
<c:when test="${s == 'c'}">
<c:out value="${sA[2]}"/>
</c:when>
<c:when test="${s == 'd'}">
<c:out value="${sA[3]}"/>
</c:when>
</c:choose>
</c:forEach>
</body>
</html>
renders this to my browser:
a b c d
So it puts spaces between each chars
But when I put all the codes from forEach to /forEach, it renders without additional spaces:
<c:forEach var="s" items="${sA}" varStatus="status"> .... all the c:choose and stuff goes here ... </c:forEach>
abcd
Can I force the renderer somehow to not to put spaces? I know that putting everything into one line solves my problem, but I don't want to do that, no one can ever read or modify that jsp again. My actual jsp has about 50 c:when tags, it would be quite a disgusting ugly code formatting and jsp page at the end...
Thanks for the help!
Kumite