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 BB2AB7AA6 for ; Wed, 7 Dec 2011 10:09:08 +0000 (UTC) Received: (qmail 33787 invoked by uid 500); 7 Dec 2011 10:09:04 -0000 Delivered-To: apmail-tomcat-users-archive@tomcat.apache.org Received: (qmail 33718 invoked by uid 500); 7 Dec 2011 10:09:04 -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 33671 invoked by uid 99); 7 Dec 2011 10:09:04 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 07 Dec 2011 10:09:04 +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 (nike.apache.org: local policy) Received: from [217.72.192.248] (HELO fmmailgate07.web.de) (217.72.192.248) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 07 Dec 2011 10:08:56 +0000 Received: from web.de by fmmailgate07.web.de (Postfix) with ESMTP id F2658B9586D for ; Wed, 7 Dec 2011 11:08:34 +0100 (CET) Received: from [88.101.217.48] by mwmweb087 with HTTP; Wed Dec 07 11:08:34 CET 2011 Date: Wed, 7 Dec 2011 11:08:34 +0100 (CET) From: "Jochen Gazda" To: "Tomcat Users List" Message-ID: <1818015120.799135.1323252514975.JavaMail.fmail@mwmweb087> Subject: Re: Occurence of Byte Order Mark (BOM) in responses varies between identical subsequent requests in Tomcat 6.0.35 MIME-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Priority: 3 Importance: normal Sensitivity: Normal X-Provags-ID: V01U2FsdGVkX1+gV6pQLz54dDH4Lo8/VGj4xj6l2okoUDPr6ygkqlIyZyyIV85VRyB3 cVYUbM7qLgB/nQLN0+14eg== X-Virus-Checked: Checked by ClamAV on apache.org -----Urspr=C3=BCngliche Nachricht----- Von: "Pid *" Gesendet: Dec 7, 2011 10:26:00 AM An: "Tomcat Users List" Betreff: Re: Occurence of Byte Order Mark (BOM) in responses varies between= identical subsequent requests in Tomcat 6.0.35 >On 7 Dec 2011, at 09:11, Jochen Gazda wrote: > >> Gentlemen, >> >> The following occurs on Tomcat 6.0.20 or 6.0.35 on 64bit Linux >> $ java -version >> java version "1.6.0_26" >> Java(TM) SE Runtime Environment (build 1.6.0_26-b03) >> Java HotSpot(TM) 64-Bit Server VM (build 20.1-b02, mixed mode) >> >> It happends both with and without apache httpd frontend. >> >> I have a very simple servlet doing basically the following: >> >> protected void doGet(HttpServletRequest request, >> HttpServletResponse response) throws ServletException, IOException { >> response.setContentType("text/xml"); >> response.setCharacterEncoding("utf-16"); >> PrintWriter w =3D response.getWriter(); >> w.write(""); >> } > >Are you also closing this writer, as below? > > >p > >> >> The first response after the start of tomcat contains the fe ff BOM >> <=3D Recv data, 8850 bytes (0x2292) >> 0000: 32 30 30 30 0d 0a fe ff 00 3c 00 3f 00 78 00 6d 2000.....<.?.x.m >> 0010: 00 6c 00 20 00 76 00 65 00 72 00 73 00 69 00 6f .l. .v.e.r.s.i.o >> >> But there is no BOM in an indentical subsequent request >> <=3D Recv data, 8850 bytes (0x2292) >> 0000: 32 30 30 30 0d 0a 00 3c 00 3f 00 78 00 6d 00 6c 2000...<.?.x.m.l >> 0010: 00 20 00 76 00 65 00 72 00 73 00 69 00 6f 00 6e . .v.e.r.s.i.o.n >> >> The more exact observation of me is that there is no BOM in a majority o= f subsequent identical requests. The BOM comes sometimes. >> >> I guess there is some writer, buffer or encoder not recycled properly. >> >> May I file a bug for this? >> >> Workaround: >> BOM seems to be always there if the java.io.OutputStreamWriter is used i= nstead of tomcat's response.getWriter(): >> protected void doGet(HttpServletRequest request, >> HttpServletResponse response) throws ServletException, IOException { >> response.setContentType("text/xml"); >> response.setCharacterEncoding("utf-16"); >> ServletOutputStream out =3D response.getOutputStream(); >> Writer w =3D null; >> try { >> w =3D new OutputStreamWriter(out, response.getCharacterEncoding()); >> w.write(""); >> } finally { >> if (w !=3D null) { >> try { >> w.close(); >> } catch (Exception e) { >> log("Could not close writer", e); >> } >> } >> } >> } >> >> Best, >> >> Gazda >> >Are you also closing this writer, as below? No. Would it make a difference? Best, Gazda ___________________________________________________________ SMS schreiben mit WEB.DE FreeMail - einfach, schnell und kostenguenstig. Jetzt gleich testen! http://f.web.de/?mc=3D021192 --------------------------------------------------------------------- To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org For additional commands, e-mail: users-help@tomcat.apache.org