I have a servlet that generates some text. The purpose of this is to have a simple status page for an application that can easily be parsed, therefor I'd like to avoid html.
Everything works fine, except that linebreaks get swallowed somewhere in the process.
I tried \r
\r\n
\n
but the result in the browser always looks the same: everything that might look like a line break just disapears and everything is in one looooong line. Which makes it next to impossible to read (both for machines and humans).
Firefox does confirm that the result is of type text/plain
So how do I get line breaks in a text/plain document, that is supposed to be displayed in a browser and generated by a servlet?
update:
Other things that do not work:
println
System.getProperty("line.separator")
Content-Type: text/plain
then your output of carriage return and line feed should be displayed as a line break in the browser. – Biauriculate