Return-Path: X-Original-To: apmail-tomcat-users-archive@www.apache.org Delivered-To: apmail-tomcat-users-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 3584F10215 for ; Mon, 13 Jan 2014 14:05:47 +0000 (UTC) Received: (qmail 54272 invoked by uid 500); 13 Jan 2014 13:58:04 -0000 Delivered-To: apmail-tomcat-users-archive@tomcat.apache.org Received: (qmail 54098 invoked by uid 500); 13 Jan 2014 13:57:50 -0000 Mailing-List: contact users-help@tomcat.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: "Tomcat Users List" Delivered-To: mailing list users@tomcat.apache.org Received: (qmail 54049 invoked by uid 99); 13 Jan 2014 13:57:42 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 13 Jan 2014 13:57:42 +0000 X-ASF-Spam-Status: No, hits=-0.0 required=5.0 tests=RCVD_IN_DNSWL_NONE,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (athena.apache.org: domain of da.asok@gmail.com designates 209.85.192.174 as permitted sender) Received: from [209.85.192.174] (HELO mail-pd0-f174.google.com) (209.85.192.174) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 13 Jan 2014 13:57:37 +0000 Received: by mail-pd0-f174.google.com with SMTP id w10so2740548pde.19 for ; Mon, 13 Jan 2014 05:57:17 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=subject:references:from:content-type:in-reply-to:message-id:date:to :content-transfer-encoding:mime-version; bh=3/j+X/rqPfGgVutTwfzn6E7fDDZGXaw3Zh/A/V4ni4w=; b=faug7D5fXxG5e8nsiAl2OOtSnS+FcJmv5OHWJZXvob6e2GTAufPWlIdU0HJZjB4n9H p2EBcOow0tfWixXWxLoDe/4zEgM3kTxnvZK4szuwOoOMtxE2m9PufnipyQHlVz/Ouelm gNuHGLLq1kHGL8sTj5EdCGQBn1rIiCnOlXtY7xgaxW4VZUudduP2uzzVxkdgk0clKePq mkUvFPo4RNI6ty6KDFfSetWkeWrh6/bH1MNgMiFR2fx9NwNNvAsdwx0bUDqT6yC57Lb4 SrwkPCxnLaYVRVHrB7fGkltpjiS1jZtbjUqN+MO8MefZGu4ACJRBlYlYn1ga3u+GCvHY qMZg== X-Received: by 10.66.192.38 with SMTP id hd6mr3569758pac.146.1389621437451; Mon, 13 Jan 2014 05:57:17 -0800 (PST) Received: from [10.119.99.189] (amx5-2.starhub.net.sg. [203.116.112.15]) by mx.google.com with ESMTPSA id vf7sm38379666pbc.5.2014.01.13.05.57.14 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 13 Jan 2014 05:57:16 -0800 (PST) Subject: Re: Tomcat strips CRLFs from the generated page References: <854E18E8-AA6D-442E-B6C1-AC95B9A39728@gmail.com> From: Asok Chattopadhyay Content-Type: text/plain; charset=us-ascii X-Mailer: iPhone Mail (9B206) In-Reply-To: Message-Id: Date: Mon, 13 Jan 2014 21:57:04 +0800 To: Tomcat Users List Content-Transfer-Encoding: quoted-printable Mime-Version: 1.0 (1.0) X-Virus-Checked: Checked by ClamAV on apache.org No, I don't have any filter, except for a session counter listener. I am goi= ng to make a demo servlet and post it soon once I am back at home, Thanks Dan. I really appreciate your help, Sent from my iPhone On 13 Jan, 2014, at 9:36 PM, Daniel Mikusa wrote: > On Jan 13, 2014, at 8:26 AM, Asok Chattopadhyay wrote:= >=20 >> I checked the string, say, s, just before and after writing it to the Pri= ntWriter. >>=20 >> PrintWriter out=3Dresponse.getWriter(); >> Print("before=3D"+s); >> out.println(s); >> out.flush(); >> out.close(); >> Print("after=3D"+s); >>=20 >> where Print is a static method printing on the log file localhost...log >>=20 >> And the log shows no change. Obviously it looks like whatever is happenin= g is happening in out.println. >=20 > No, not necessarily. It is quite possible for a servlet Filter to modify w= hat you're writing to the output stream. Does your application have any fil= ters in place? >=20 > Also, can you provide a demo servlet that replicates this behavior? >=20 > Thanks >=20 > Dan >=20 >>=20 >>=20 >>=20 >> Sent from my iPhone >>=20 >> On 13 Jan, 2014, at 8:48 PM, Daniel Mikusa wrote:= >>=20 >>> On Jan 13, 2014, at 6:09 AM, Asok Chattopadhyay wrot= e: >>>=20 >>>> Hi, >>>>=20 >>>> My servlet generates a page containing embedded JavaScript and sometime= s >>>> the page received in the browser comes with CRLFs stripped from the tex= t, >>>> starting at some point in the text. This creates a big problem if the >>>> script contains CRLF as statement separator instead of semi-colon. It's= >>>> strange that not the entire text is stripped. Say, the first 150 lines >>>> comes as it is, whereas starting from line 151, all the CRLFs are strip= ped. >>>> It is fairly consistent for the same page. >>>=20 >>> Sounds like an application / servlet error. Have you tried hooking up a= debugger and stepping through your code? >>>=20 >>> Also, do you see this consistently across all servlets in your app or ju= st one? >>>=20 >>>>=20 >>>> I am using Tomcat 6.0.37. >>>>=20 >>>> Why does it happen? Is anything in the text triggers this? Is there a w= ay >>>> to overcome this problem, as I don't have control over the actual conte= nt? >>>=20 >>> Seems unlikely that Tomcat would be doing this. Check your servlet code= . Check if you have any filters in your application, perhaps one is modifyi= ng the content. >>>=20 >>> Dan >>>=20 >>>>=20 >>>>=20 >>>> Thanks in advance. >>>>=20 >>>> Here is the example. >>>>=20 >>>>=20 >>>> LINE 148: >>>>=20 >>>> LINE 149: >>>>=20 >>>> LINE 150: >>>>=20 >>>> LINE 151: >>> onload=3D"topBottom();move_caret('one','xcrnnum');" >>>> style=3D"margin:0;padding:0;">