How do i insert white space in the below statement in java class but the string gets displayed in jsp page.As \n\t does not work on jsp.How do i insert white space for jsp?
sb.append("\n\tStackflow: "+"<br>");
You should realize that JSP is merely a HTML code generator. Whitespace in HTML source code is by default not accounted as part of human presentation. It's by default collapsed to a single space. The average website would otherwise have looked very ugly. Copypaste for example this in browser's address bar while looking at stackoverflow.com to see the effect yourself when whitespace in HTML source code would be accounted:
javascript:$("*").css("white-space", "pre");
If you want to preserve whitespace as-is in HTML source code, you'd need to put the desired piece of HTML inside a <pre>
element
<pre>
...
</pre>
Or to apply CSS white-space: pre;
style on the parent element.
<div style="white-space: pre;">
...
</div>
make use of
(non breaking space)
sb.append(" Stackflow: "+"<br>");
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With