1 Reply Latest reply: Jun 12, 2014 8:43 AM by gimbal2 RSS

    Trim Whitespace too greedy?

    user4532643

      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?

       

      Regards

        • 1. Re: Trim Whitespace too greedy?
          gimbal2

          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