I am so sorry for the troubles brought to you. 
This is my first patch to Geronimo, I will check my code more  carefully in the future.


On Wed, Aug 5, 2009 at 9:58 AM, Ivan <xhhsld@gmail.com> wrote:
Thanks, Donald, I will review those patches more carefully before committing them :-(

2009/8/5 Donald Woods <dwoods@apache.org>

Ivan, looks like the code you backported from trunk needs to be updated for 2.1.x to not include the SLF4J dependency, as that is a trunk specific change.


-Donald


xuhaihong@apache.org wrote:
Author: xuhaihong
Date: Tue Aug  4 08:56:30 2009
New Revision: 800704

URL: http://svn.apache.org/viewvc?rev=800704&view=rev
Log:
GERONIMO-4758 The Server Console page displays messy codes when set zh as the prefered language in browser(Patch from Siqi Du)

Modified:
   geronimo/server/branches/2.1/plugins/console/console-filter/src/main/java/org/apache/geronimo/console/filter/FilterResponseWrapper.java
   geronimo/server/branches/2.1/plugins/console/console-filter/src/main/java/org/apache/geronimo/console/filter/XSRFHandler.java

Modified: geronimo/server/branches/2.1/plugins/console/console-filter/src/main/java/org/apache/geronimo/console/filter/FilterResponseWrapper.java
URL: http://svn.apache.org/viewvc/geronimo/server/branches/2.1/plugins/console/console-filter/src/main/java/org/apache/geronimo/console/filter/FilterResponseWrapper.java?rev=800704&r1=800703&r2=800704&view=diff
==============================================================================
--- geronimo/server/branches/2.1/plugins/console/console-filter/src/main/java/org/apache/geronimo/console/filter/FilterResponseWrapper.java (original)
+++ geronimo/server/branches/2.1/plugins/console/console-filter/src/main/java/org/apache/geronimo/console/filter/FilterResponseWrapper.java Tue Aug  4 08:56:30 2009
@@ -16,16 +16,22 @@
 */
 package org.apache.geronimo.console.filter;
 +import java.io.BufferedWriter;
 import java.io.ByteArrayOutputStream;
 import java.io.IOException;
 import java.io.OutputStream;
+import java.io.OutputStreamWriter;
 import java.io.PrintWriter;
+import java.io.UnsupportedEncodingException;
  import javax.servlet.ServletOutputStream;
 import javax.servlet.ServletResponse;
 import javax.servlet.http.HttpServletResponse;
 import javax.servlet.http.HttpServletResponseWrapper;
 +import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
 /**
 * Implementation of a HttpServletResponseWrapper to allow us to edit the
 * response content from the filter chain/servlet before committing it to
@@ -34,6 +40,7 @@
 * @version $Rev$ $Date$
 */
 public final class FilterResponseWrapper extends HttpServletResponseWrapper {
+       private static final Logger log = LoggerFactory.getLogger(FilterResponseWrapper.class);
    private ByteArrayOutputStream output = null;
    private ResponseOutputStream stream = null;
    private PrintWriter writer = null;
@@ -168,7 +175,13 @@
        }
        this.output = new ByteArrayOutputStream();
        this.stream = new ResponseOutputStream(output);
-        this.writer = new PrintWriter(stream);
+        try{
+               this.writer = new PrintWriter(new BufferedWriter(new OutputStreamWriter(stream, "UTF-8")));
+        }
+        catch (UnsupportedEncodingException uee) {
+            // should never happen
+            log.error("new OutputStreamWriter(stream, UTF-8) failed.", uee);
+        }
    }
      /* (non-Javadoc)

Modified: geronimo/server/branches/2.1/plugins/console/console-filter/src/main/java/org/apache/geronimo/console/filter/XSRFHandler.java
URL: http://svn.apache.org/viewvc/geronimo/server/branches/2.1/plugins/console/console-filter/src/main/java/org/apache/geronimo/console/filter/XSRFHandler.java?rev=800704&r1=800703&r2=800704&view=diff
==============================================================================
--- geronimo/server/branches/2.1/plugins/console/console-filter/src/main/java/org/apache/geronimo/console/filter/XSRFHandler.java (original)
+++ geronimo/server/branches/2.1/plugins/console/console-filter/src/main/java/org/apache/geronimo/console/filter/XSRFHandler.java Tue Aug  4 08:56:30 2009
@@ -217,7 +217,7 @@
                // only update the content if it is HTML
                if (cType.toLowerCase().indexOf("html") != -1) {
                    // get the response content
-                    String content = new String(hres.getOutput());
+                    String content = new String(hres.getOutput(), "UTF-8");
                    // update the JavaScript with the uniqueId for this session
                    updatedXsrfJS = xsrfJS.replace(XSRF_JS_UNIQUEID, uniqueId);
                    // update the response to contain the JS fragment






--
Ivan