jakarta-cactus-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Vincent Massol" <vmas...@pivolis.com>
Subject [Help] Servlet response's encoding of new lines, what is the correct behavior?
Date Wed, 24 Mar 2004 15:08:16 GMT

I need your help. We have one test in the Cactus test suite that tests
servlet response:

    public void testGetResponseAsStringMultiLines() throws IOException
        PrintWriter pw = response.getWriter();

        pw.println("<body>A GET request</body>");

    public void endGetResponseAsStringMultiLines(WebResponse
        throws IOException
        StringWriter sw = new StringWriter();
        PrintWriter pw = new PrintWriter(sw);

        pw.println("<body>A GET request</body>");

        String result = theResponse.getText();

        assertEquals(sw.toString(), result);


The problem is that this test works fine on Orion 1.x, Orion 2.x and
Resin 2.x but it fails on Tomcat 4.1.30, Tomcat 3.x and Resin 3.x.

The container where the test succeeds are those returning Windows eol
characters (\r\n) whereas those that fail return Unix eol (\n).

Is there a way (through some encoding?) to control how the response
stream should encode end of lines?

Note: I've tried using:
response.setContentType("text/html;charset=ISO-8859-1"); (this is the
default). But it doesn't help. I'm really not proficient in encoding and
I'm not sure that encodings specify how eol are built ("\n" vs "\r\n").

Any idea?

Thanks for the help

View raw message