myfaces-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Tomas <tomas_pol...@yahoo.com>
Subject Newlines in HTTP response with text/plain
Date Sat, 16 Aug 2008 17:05:28 GMT
Hello,

I don't know if this is the correct list for posting this question, but I have looked everywhere
without finding an answer.

I have a web application that generates a String dynamically, and the user can download this
as a text file.
The way to implement this is to obtain the ServletOutputStream for the response and writing
the String directly, at the same time setting the "content type" for the response as "text/plain".

The problem is that the newlines are interpreted differently under Windows or Linux. If I
generate the String using '\n' then the file looks wrong when opened with Notepad. And if
I generate the String using '\r\n' then it's wrong when opened with vi under Linux.

I have thought about setting the correct newline using System.getProperty("line.separator"),
but that uses the correct newline for the server platform, not for the client platform.

I have also thought about parsing the user agent HTTP header, but that seems to me to be too
much trouble and not a robust solution.

Do you know what's the correct approach for this problem?

Thanks very much in advance.
Cheers,
Tomás



      
Mime
View raw message