1 Reply Latest reply on Jun 12, 2014 1:43 PM by gimbal2

    Trim Whitespace too greedy?


      Hi all,


      when using trim-directive-whitespaces in a Tomcat 7 application this expression also get trimmed:


      <div class="${item.view} ${item.className}">


      resulting in the HTML


      <div class="personchild">


      instead of


      <div class="person child">


      On the other hand, when I first assign the expression to a varibale it's fine:

      <c:set var="className" value="${item.view} ${item.className}"/>

      <div class="${className}">


      results in the desired HTML


      <div class="person child">



      Is this the intention of the trim whitespace directive or does this look like a bug?



        • 1. Re: Trim Whitespace too greedy?

          Well this is not the place to ask about possible bugs in Tomcat; that is of course a question for the Apache mailing lists. Be sure to mention the minor version of Tomcat 7 you're using when you do that. You are also missing one test case in your problem description. What happens when you don't specify that page directive at all? Do you get the desired output then? Probably yes but it saves time to close all the gaps.


          In any case, this stackoverflow thread might contain an alternative tomcat-specific solution to your requirement, but I don't know if it still works in Tomcat 7 and up:


          tomcat - Strip whitespace from jsp output - Stack Overflow