i want to display multiline data retrieved from database as such..with spaces in a jsp page ..but out.println always trims and display it..im using tomcat as server..is there any other way to prevent trimming
The out.println method trims nothing. It only adds a new line character to the end. (out.print doesn't add a new line).
To better understand Satou's post, try viewing the HTML source from your browser's "Menu -> View -> View Source" option. You will see that all the whitespace is still there.
Browsers ignore whitespace when rendering HTML becuase they are supposed to. There are HTML tags for spaces and new lines. Use for a space and <br /> for a line break. You will need to parse your database results and substitute spaces and line breaks with these symbols.
Two other alternatives are: 1.) Use the <pre> your text </pre> tags. 2.) Display the literal text in a <textarea>your text</textarea> control. [ July 19, 2006: Message edited by: Ben Souther ]