Put all the statements on a single line. The newline in JSP puts a space in HTML.
<c:if test="${formtMins==0}">0</c:if> ${formtMins}:${formHours} <c:if test="${formHours<10}">0</c:if>
Is not very nice but it works as far as I remember.
Question
i used to print time but i found white spaces between date hours and minutes, i used to format the time as follows:
<fmt:formatDate var="formtMins" pattern="m" type="TIME" timeStyle="default" value="${exam.to}" />
<fmt:formatDate var="formHours" pattern="h" type="TIME" timeStyle="default" value="${exam.to}" />
Given that: exam.to
is a date object, i used to put additional zeros if the minutes is zero or the hours is less than 10 as follows:
<c:if test="${formtMins==0}">0</c:if>
${formtMins}:
${formHours}
<c:if test="${formHours<10}">0</c:if>
the previous code prints the time as follows:
12 : 0 0
0 4 :46
0 2 : 0 0
the spaces appears when i added the additional zeros and its not preferred, so i tried to remove any white space as follows but unfortunately it doesn't work:
<c:if test="${formtMins==0}">0${fnc:trim('')}</c:if>
${fnc:trim(formtMins)}:
${fnc:trim(formHours)}
<c:if test="${formHours<10}">0${fnc:trim('')}</c:if>
so the question is how to remove the this white spaces between the time?
Solution 2
Put all the statements on a single line. The newline in JSP puts a space in HTML.
<c:if test="${formtMins==0}">0</c:if> ${formtMins}:${formHours} <c:if test="${formHours<10}">0</c:if>
Is not very nice but it works as far as I remember.
OTHER TIPS
Try using
<%@ page trimDirectiveWhitespaces="true" %>
on your JSP page, or
<jsp-config>
<jsp-property-group>
<url-pattern>*.jsp</url-pattern>
<trim-directive-whitespaces>true</trim-directive-whitespaces>
</jsp-property-group>
</jsp-config>
in your web.xml
to configure white space trimming for all JSP pages.
This is kind of greedy. If you need a space after EL or a tag, you could use ${' '}
.