Index: /home/Lutz/.eclipse/JSPWiki263/src/com/ecyrd/jspwiki/ui/WikiJSPFilter.java
===================================================================
--- /home/Lutz/.eclipse/JSPWiki263/src/com/ecyrd/jspwiki/ui/WikiJSPFilter.java	(revision 686018)
+++ /home/Lutz/.eclipse/JSPWiki263/src/com/ecyrd/jspwiki/ui/WikiJSPFilter.java	(working copy)
@@ -19,9 +19,7 @@
  */
 package com.ecyrd.jspwiki.ui;
 
-import java.io.CharArrayWriter;
-import java.io.IOException;
-import java.io.PrintWriter;
+import java.io.*;
 
 import javax.servlet.*;
 import javax.servlet.http.HttpServletRequest;
@@ -81,7 +79,8 @@
 
             w.enterState("Filtering for URL "+((HttpServletRequest)request).getRequestURI(), 90 );
           
-            HttpServletResponseWrapper responseWrapper = new MyServletResponseWrapper( (HttpServletResponse)response );
+//            HttpServletResponseWrapper responseWrapper = new MyServletResponseWrapper( (HttpServletResponse)response );
+            GenericResponseWrapper wrapper = new GenericResponseWrapper((HttpServletResponse) response); 
         
             // fire PAGE_REQUESTED event
             String pagename = DefaultURLConstructor.parsePageFromURL(
@@ -88,7 +87,8 @@
                     (HttpServletRequest)request, response.getCharacterEncoding() );
             fireEvent( WikiPageEvent.PAGE_REQUESTED, pagename );
 
-            super.doFilter( request, responseWrapper, chain );
+//            super.doFilter( request, responseWrapper, chain );
+            super.doFilter( request, wrapper, chain );
 
             // The response is now complete. Lets replace the markers now.
         
@@ -99,7 +99,8 @@
             {
                 w.enterState( "Delivering response", 30 );
                 WikiContext wikiContext = getWikiContext( request );
-                String r = filter( wikiContext, responseWrapper );
+//                String r = filter( wikiContext, responseWrapper );
+                String r = filter( wikiContext, wrapper );
         
                 //String encoding = "UTF-8";
                 //if( wikiContext != null ) encoding = wikiContext.getEngine().getContentEncoding();
@@ -140,9 +141,11 @@
      * @param string The source string
      * @return The modified string with all the insertions in place.
      */
-    private String filter(WikiContext wikiContext, HttpServletResponse response )
+//    private String filter(WikiContext wikiContext, HttpServletResponseWrapper response )
+    private String filter(WikiContext wikiContext, GenericResponseWrapper response )
     {
-        String string = response.toString();
+//        String string = response.toString();
+        String string = response.getString();
 
         if( wikiContext != null )
         {
@@ -223,6 +226,90 @@
     }
     
     /**
+     *  Generic response wrapper that uses ByteArrayOutputStream instead of
+     *  CharArrayWriter. Fix for Oracle Container for J2EE (OC4J 10.1.3.1)
+     *  
+     *  @author ltietze
+     */
+    private static class FilterServletOutputStream extends ServletOutputStream {
+
+        private DataOutputStream stream; 
+
+        public FilterServletOutputStream(OutputStream output) { 
+          stream = new DataOutputStream(output); 
+        }
+
+        public void write(int b) throws IOException  { 
+          stream.write(b); 
+        }
+
+        public void write(byte[] b) throws IOException  { 
+          stream.write(b); 
+        }
+
+        public void write(byte[] b, int off, int len) throws IOException  { 
+          stream.write(b,off,len); 
+        } 
+
+      }    
+    private static class GenericResponseWrapper extends HttpServletResponseWrapper { 
+        private ByteArrayOutputStream output;
+        private int contentLength;
+        private String contentType;
+        private HttpServletResponse aResponse;
+
+        public GenericResponseWrapper(HttpServletResponse response) { 
+          super(response);
+          output=new ByteArrayOutputStream();
+          aResponse = response;
+        } 
+
+        public byte[] getData() { 
+          return output.toByteArray(); 
+        } 
+        
+        public String getString(){
+          try
+        {
+            return output.toString(aResponse.getCharacterEncoding());
+        }
+        catch (UnsupportedEncodingException e)
+        {
+            // TODO Auto-generated catch block
+            e.printStackTrace();
+            return null;
+        }
+        }
+
+        public ServletOutputStream getOutputStream() { 
+          return new FilterServletOutputStream(output); 
+        } 
+        
+        public PrintWriter getWriter() { 
+          return new PrintWriter(getOutputStream(),true); 
+        } 
+
+        public void setContentLength(int length) { 
+          this.contentLength = length;
+          super.setContentLength(length); 
+        } 
+
+        public int getContentLength() { 
+          return contentLength; 
+        } 
+
+        public void setContentType(String type) { 
+          this.contentType = type;
+          super.setContentType(type); 
+        } 
+
+
+        public String getContentType() { 
+          return contentType; 
+        } 
+      } 
+
+    /**
      *  Simple response wrapper that just allows us to gobble through the entire
      *  response before it's output.
      *  
