Hi,

> -----Original Message-----
> From: Asok Chattopadhyay [mailto:da.a...@gmail.com]
> Sent: Monday, January 13, 2014 6:41 PM
> To: Tomcat Users List
> Subject: Re: Tomcat strips CRLFs from the generated page
> 
> Hi,
> Sorry about that.
> Here are the locations of the two files:
> 
> (1) http://workshop.dreamapps.com/da/docs/Test.java
> (2) http://workshop.dreamapps.com/da/docs/test.html
> 
> Thanks.

I just tried your Servlet and .html locally (in Tomcat 7.0.50 on Windows, but I 
think the behavior should be the same as in TC 6), and I tried your URL 
http://workshop.dreamapps.com/da/test, but in none of them I could find any 
stripped CR LFs.

If watch the source code of that URL, then e.g. Line 373 contains 
</body></html> after a line break (CR LF), so the line breaks seem to work.


Some other points (which don't have to do with line breaks):

1) As Konstantin Kolinko noted, your .html page contains a lot of syntax errors.

2) Your .html page seems to be encoded in UTF-8, but your servlet uses the 
default encoding to decode the bytes to a String. One some platforms the 
default encoding is UTF-8, but on some like Windows it depends on the user's 
locale - one should explicitely set the used encoding. (Why are you using a 
DataInputStream to read a .html page? A InputStream should suffice for this.)

3) I wonder why you have this line in your servlet:

res.setHeader("X-UA-Compatible", "IE=EmulateIE7")

This instructs IE to behave like the outdated IE 7 which does not implement a 
lot of current HTML functionality, but on the other hand you use a HTML5 
doctype (<!DOCTYPE html>) which seems to indicate that you intent to use the 
current HTML 5 features.

4) In Java 6 or earlier, it is a good practice to use try-catch-finally with 
resources like PrintWriter; Java 7 has try-with-resources syntax.

Regards,
Konstantin Preißer


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
For additional commands, e-mail: users-h...@tomcat.apache.org

Reply via email to