Return-Path: Delivered-To: apmail-jakarta-tomcat-user-archive@apache.org Received: (qmail 50763 invoked from network); 10 Apr 2003 07:28:09 -0000 Received: from exchange.sun.com (192.18.33.10) by daedalus.apache.org with SMTP; 10 Apr 2003 07:28:09 -0000 Received: (qmail 20497 invoked by uid 97); 10 Apr 2003 07:30:12 -0000 Delivered-To: qmlist-jakarta-archive-tomcat-user@nagoya.betaversion.org Received: (qmail 20490 invoked from network); 10 Apr 2003 07:30:11 -0000 Received: from daedalus.apache.org (HELO apache.org) (208.185.179.12) by nagoya.betaversion.org with SMTP; 10 Apr 2003 07:30:11 -0000 Received: (qmail 49299 invoked by uid 500); 10 Apr 2003 07:27:43 -0000 Mailing-List: contact tomcat-user-help@jakarta.apache.org; run by ezmlm Precedence: bulk List-Unsubscribe: List-Subscribe: List-Help: List-Post: List-Id: "Tomcat Users List" Reply-To: "Tomcat Users List" Delivered-To: mailing list tomcat-user@jakarta.apache.org Received: (qmail 49281 invoked from network); 10 Apr 2003 07:27:43 -0000 Received: from f69.law10.hotmail.com (HELO hotmail.com) (64.4.15.69) by daedalus.apache.org with SMTP; 10 Apr 2003 07:27:43 -0000 Received: from mail pickup service by hotmail.com with Microsoft SMTPSVC; Thu, 10 Apr 2003 00:27:55 -0700 Received: from 61.144.207.53 by lw10fd.law10.hotmail.msn.com with HTTP; Thu, 10 Apr 2003 07:27:55 GMT X-Originating-IP: [61.144.207.53] X-Originating-Email: [hackingbear@hotmail.com] From: "hacking bear" To: tomcat-user@jakarta.apache.org Bcc: Subject: Re: Setting locale encoding in Filter Date: Thu, 10 Apr 2003 00:27:55 -0700 Mime-Version: 1.0 Content-Type: text/plain; format=flowed Message-ID: X-OriginalArrivalTime: 10 Apr 2003 07:27:55.0596 (UTC) FILETIME=[B42B00C0:01C2FF32] X-Spam-Rating: daedalus.apache.org 1.6.2 0/1000/N X-Spam-Rating: daedalus.apache.org 1.6.2 0/1000/N That's what I believe should happen but as my experiment shows the opposite happens. If I set my locale/encoding anywhere before next.doFilter(), none of the pages display properly, but if I put it after next.doFilter() then only a small number of pages sometimes (1 page display one particular data record which has nothing special than other records) showing garbage and setting encoding in that JSP page fixes the problem, as I described below. BTW I found setting the request.setCharEncoding() before next.doFilter() does do what it should be doing. >From: "Bill Barker" >Reply-To: "Tomcat Users List" >To: tomcat-user@jakarta.apache.org >Subject: Re: Setting locale encoding in Filter >Date: Thu, 10 Apr 2003 00:23:45 -0700 > >You're setLocale et. al. calls should come before 'next.doFilter'. >Otherwise (esp. with JSP pages) the response may be committed before >control >is returned to your Filter. In this case, you are now longer allowed to >change the settings (and Tomcat should throw an IllegalStateExecption). > >"hacking bear" wrote in message >news:F49dyvqSgnpvI4NNIiY00006bde@hotmail.com... > > Hello, > > > > My app needs to handle multiple locale/encoding and since the user >chooses > > locale at login I try to just set the locale encoding in a servlet >filter >so > > that I don't have to do that in every page or servlet: > > > > void doFilter(request, response, FilterChain next) { > > if (next != null) { > > next.doFilter(request, response); > > } > > response.setLocale(locale); > > response.setContentType("text/html; charset=" + encoding); > > response.addHeader("Cache-Control", "no-cache"); > > request.setCharacterEncoding(encoding); > > } > > > > 1. This almost works except some JSP pages sometimes (but not always) > > displaying '?' garbage character. But if I set the response's > > locale/encoding again at the beginning of the JSP page, the problem goes > > away. > > > > 2. If I move the set locale/encoding codes before the next.doFilter(), >then > > all pages display garbage only. > > > > Is this the right way? What do I do wrong? > > > > Thanks. > > -HB > > > > > > _________________________________________________________________ > > The new MSN 8: smart spam protection and 2 months FREE* > > http://join.msn.com/?page=features/junkmail > > > > >--------------------------------------------------------------------- >To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org >For additional commands, e-mail: tomcat-user-help@jakarta.apache.org > _________________________________________________________________ STOP MORE SPAM with the new MSN 8 and get 2 months FREE* http://join.msn.com/?page=features/junkmail --------------------------------------------------------------------- To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org For additional commands, e-mail: tomcat-user-help@jakarta.apache.org