Bug 66008

Summary: Jasper Documentation is misleading (if not wrong) about the trimSpaces option
Product: Tomcat 10 Reporter: Bernhard Seebass <seebass>
Component: DocumentationAssignee: Tomcat Developers Mailing List <dev>
Status: RESOLVED FIXED    
Severity: normal    
Priority: P2    
Version: unspecified   
Target Milestone: ------   
Hardware: All   
OS: All   

Description Bernhard Seebass 2022-04-12 09:00:19 UTC
The documentation "Jasper 2 JSP Engine How To" (https://tomcat.apache.org/tomcat-10.0-doc/jasper-howto.html) states under Production Configuration:

trimSpaces - To remove useless bytes from the response, set this to true.

This is misleading and dangerous (if not just plain wrong):

trimSpace=true removes all spaces between jsp-tags and therefore may affect output.

Example: The following line will print differently with trimSpaces=true than with trimSpaces=false

<bean:write name="person" property="firstName"/> <bean:write name="person" property="familyName"/>



The text in the documentation should be changed to: 
trimSpaces - To remove useless bytes from the response, set this to single.


The same applies to Tomcat 9

Previous Tomcat versions don't have the "single" option. For these tomcats, that misleading line should be removed or at least a warning should be added, that output may look different if trimSpaces is enabled.
Comment 1 Christopher Schultz 2022-04-13 16:49:42 UTC
This seems like a matter of opinion over the definition of "useless".

The whole point of the option *is* to affect the output.

The documentation could be improved for "Production Configuration" to (a) be less forceful about using trimSpaces and (b) encourage the user to read the complete documentation for that configuration item instead of simply recommending the value of "true".

Patches are always welcome.
Comment 2 Bernhard Seebass 2022-04-14 10:27:25 UTC
(In reply to Christopher Schultz from comment #1)
> This seems like a matter of opinion over the definition of "useless".
> 
> The whole point of the option *is* to affect the output.
> 

Thanks for your reply!

I agree that it is a question about what is "useless". However, it seems obvious to me, that nobody would call a single space between two words "useless", which brings me to the conclusion, that the documentation is wrong about recommending trimSpace=true (instead of trimSpaces=single) to remove useless spaces.

I also agree, that the option should indeed affect the html-output, however nobody should be encouraged to use trimSpaces=true for production only, as this may have the effect, that the productive web page may be broken (due to missing spaces) while in development everything looked fine.


I'm sorry to say, I have no idea how to submit a patch that might fix the documentation.
Comment 3 Christopher Schultz 2022-04-14 13:06:50 UTC
(In reply to Bernhard Seebass from comment #2)
> I'm sorry to say, I have no idea how to submit a patch that might fix the
> documentation.

Are you comfortable modifying HTML (and XML)? Making the changes is relatively easy. Producing a patch file (or PR) requires that you interact with the revision-control system (git or GitHub) or keep a copy of the original file(s) around.

If you're willing, I can walk you through that process. (Post to the dev@ mailing list and I'll walk you through it, there, instead of saving the whole conversation into Bugzilla.)
Comment 4 Mark Thomas 2022-04-28 18:55:18 UTC
Fixed in:
- 10.1.x for 10.1.0-M15 onwards
- 10.0.x for 10.0.21 onwards
- 9.0.x for 9.0.63 onwards
- 8.5.x for 8.5.79 onwards

For 9.0.x onwards, I changed the recommendation to single or extended.
For 8.5.x, I removed the recommendation.