This thread has gotten too long to ignore :-) "trimSpaces" probably won't do it for you.
As my bit, I tried this trivial JSP: <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %><%-- --%><tag attr="foo('<jsp:include page="test.jsp" />')"><%-- --%><anotherTag /> where test.jsp is another trivial JSP as follows: <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %><%-- --%>A, <c:if test="${true}"><%-- --%>B, <%-- --%></c:if>C I don't have a newline after "</c:if>C", and I get this output: <tag attr="foo('A, B, C')"><anotherTag /> Ugly code? Yes. But I believe the output is similar to what you want from your example. Now why it doesn't work for you is another issue. I'm using Tomcat and Emacs. -Rahul