You should understand that JSP is just an HTML code generator. Spaces in the HTML source code are not taken into account as part of the human presentation by default. It collapses into one space by default. An average website would otherwise look very ugly. Copypaste, for example, is in the browser address bar when browsing stackoverflow.com to see the effect when spaces in the HTML source code are taken into account:
javascript:$("*").css("white-space", "pre");
If you want to keep the space as it is in the HTML source, you need to place the desired HTML fragment inside the <pre> element
<pre> ... </pre>
Or apply CSS style white-space: pre; to the parent element.
<div style="white-space: pre;"> ... </div>
source share