1

I have a function that transforms XML according to a XSLT. To test it, I'm using it in a jsp but it's entering a lot of breaks before my output. It seems to be the breaks I enter when setting variables:

<c:set var="blah" value="blah" />
<c:set var="blah2" value="blah2" />

That will show two line breaks before the output. Is there a way to avoid this with XML? I tried adding trimDirectiveWhitespaces="true" but it didn't help.

ravun
  • 1,523
  • 9
  • 27
  • 45
  • Possible duplicate of [Strip whitespace from jsp output](http://stackoverflow.com/questions/208736/strip-whitespace-from-jsp-output) – BalusC May 16 '16 at 14:29

1 Answers1

2

If you are using Tomcat to parse your jsp, you can have a go with:

<init-param>
    <param-name>trimSpaces</param-name>
    <param-value>true</param-value>
</init-param>

In your web.xml. YMMV

Else, I think that JSP 2.1 supports the following:

The last solution is any of this doesn't work is to implement a filter between your JSP rendering and your XSLT computation. A simple filter can be called to trim the spaces around the generated body.

Oct
  • 1,505
  • 13
  • 18