How can I strip out extra whitespace from jsp pages’ output? Is there a switch I can flip on my web.xml? Is there a Tomcat specific setting?
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
There is a trimWhiteSpaces directive that should accomplish this,
In your JSP:
Or in the jsp-config section your web.xml (Note that this works starting from servlet specification 2.5.):
Unfortunately if you have a required space it might also need strip that, so you may need a non-breaking space in some locations.