Commits

Anonymous committed 7ccdb36

Applied WW-526: Velocity using include ignores character encoding.

git-svn-id: http://svn.opensymphony.com/svn/webwork/trunk@578573baa09-0c28-0410-bef9-dab3c582ae83

  • Participants
  • Parent commits c9248f9

Comments (0)

Files changed (1)

src/java/com/opensymphony/webwork/util/WebWorkUtil.java

 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
 import javax.servlet.http.HttpServletResponseWrapper;
-import java.io.ByteArrayOutputStream;
 import java.io.IOException;
-import java.io.OutputStreamWriter;
 import java.io.PrintWriter;
+import java.io.StringWriter;
 import java.net.URLEncoder;
 import java.util.Hashtable;
 import java.util.Map;
             dispatcher.include(aRequest, responseWrapper);
 
             return responseWrapper.getData();
-        } catch (Exception e) {
+        }
+        catch (Exception e) {
             e.printStackTrace();
             throw e;
         }
     //~ Inner Classes //////////////////////////////////////////////////////////
 
     static class ResponseWrapper extends HttpServletResponseWrapper {
-        ByteArrayOutputStream bout;
+        StringWriter strout;
         PrintWriter writer;
         ServletOutputStream sout;
 
         ResponseWrapper(HttpServletResponse aResponse) {
             super(aResponse);
-            bout = new ByteArrayOutputStream();
-            sout = new ServletOutputStreamWrapper(bout);
-            writer = new PrintWriter(new OutputStreamWriter(bout));
+            strout = new StringWriter();
+            sout = new ServletOutputStreamWrapper(strout);
+            writer = new PrintWriter(strout);
         }
 
         public String getData() {
             writer.flush();
 
-            return bout.toString();
+            return strout.toString();
         }
 
         public ServletOutputStream getOutputStream() {
     }
 
     static class ServletOutputStreamWrapper extends ServletOutputStream {
-        ByteArrayOutputStream stream;
+        StringWriter writer;
 
-        ServletOutputStreamWrapper(ByteArrayOutputStream aStream) {
-            stream = aStream;
+        ServletOutputStreamWrapper(StringWriter aWriter) {
+            writer = aWriter;
         }
 
         public void write(int aByte) {
-            stream.write(aByte);
+            writer.write(aByte);
         }
     }
 }