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 5670A911D for ; Tue, 6 Dec 2011 16:16:06 +0000 (UTC) Received: (qmail 17578 invoked by uid 500); 6 Dec 2011 16:16:02 -0000 Delivered-To: apmail-tomcat-users-archive@tomcat.apache.org Received: (qmail 17514 invoked by uid 500); 6 Dec 2011 16:16:02 -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 17505 invoked by uid 99); 6 Dec 2011 16:16:02 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 06 Dec 2011 16:16:02 +0000 X-ASF-Spam-Status: No, hits=-0.7 required=5.0 tests=RCVD_IN_DNSWL_LOW,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (athena.apache.org: domain of knst.kolinko@gmail.com designates 209.85.212.45 as permitted sender) Received: from [209.85.212.45] (HELO mail-vw0-f45.google.com) (209.85.212.45) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 06 Dec 2011 16:15:56 +0000 Received: by vbbu11 with SMTP id u11so6400221vbb.18 for ; Tue, 06 Dec 2011 08:15:36 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type:content-transfer-encoding; bh=lHvp674loKcF5IuW4X5VEGF4w4aMJJMwU4WW+ZooAuY=; b=Q8AXYWhVcr0uT4oqKxN+tauvIyITWmibyseKi8npYmnMwq9IsE2XmLI1fjAjEq2bCM C6iyFFbRTdrLif9TTQR6GYnPNKJIqqjTNq7rEhZpHVqQsj9GwqTRJlgIj5J6SCgdrWHP vioMOdypdDck+dTNkp+MRuaSCjrs21frQjJcg= MIME-Version: 1.0 Received: by 10.52.97.34 with SMTP id dx2mr8341031vdb.3.1323188136068; Tue, 06 Dec 2011 08:15:36 -0800 (PST) Received: by 10.52.110.4 with HTTP; Tue, 6 Dec 2011 08:15:36 -0800 (PST) In-Reply-To: <4EDE317D.9090005@christopherschultz.net> References: <4EDBECB9.2090302@ice-sa.com> <4EDE317D.9090005@christopherschultz.net> Date: Tue, 6 Dec 2011 20:15:36 +0400 Message-ID: Subject: Re: Character set issue From: Konstantin Kolinko To: Tomcat Users List Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable 2011/12/6 Christopher Schultz : > On 12/4/11 8:02 PM, Konstantin Kolinko wrote: >> Make sure that content type and charset value in a) Content-Type >> HTTP header sent by server and b) in META tag in HTML text have >> _literally_ the same value. If they both are present and they do >> not match, odd things may happen in "non-compliant" browsers. > > I almost always do the following at the top of my pages (JSP shows, > but you get the idea for any templating system): > > > > =A0 =A0 =A0 =A0 =A0content=3D"text/html<% null =3D=3D response.getCharacterEn= coding() > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 ? "" > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 : ";" + response.= getCharacterEncoding() %>" > =A0/> > > I do this so that, in case the response encoding gets changed from > whatever I think it is, I don't report the wrong one. You don't want > the page to say UTF-8 when the encoding is really SHIFT-JS or > something else. > :) I always do similar, but a bit more simple implementation of the above: <%=3D response.getContentType() %> 2011/12/6 Christopher Schultz : > On 12/5/11 6:53 PM, Konstantin Kolinko wrote: >> Note, that there is standard "SetCharacterEncodingFilter" in Tomcat >> 7. (In 7.0 it is in o.a.c.filters package, in 6.0 and 5.5 it is >> examples webapp). > > I see that you've moved that out of examples and into the main code base. > > Should we also provide a Valve version of this? That way, you can make > sure that the encoding is set before Valves like the > AuthenticatorValve fire. > 1. I do not use valves that call getParameter(), so I have not seen the need, but the FormAuthenticator will need the feature? Anyone who have an itch can implement the valve. 2. I sometimes wonder whether URIEncoding setting on a Connector can be moved to a Context instead. 3. Maybe backport the move of SetCharacterEncodingFilter to 6.0. Best regards, Konstantin Kolinko --------------------------------------------------------------------- To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org For additional commands, e-mail: users-help@tomcat.apache.org