And then finally resolved: //create a buffered reader BufferedReader br = new BufferedReader(new InputStreamReader(in,"UTF-8"));
The solution was I needed to create a UTF-8 InputStreamReader. Doh. Anyway problem solved.:) Rob -----Original Message----- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Robert Edgar Sent: Thursday, June 21, 2007 2:25 PM To: 'General Discussion for the Resin application server' Subject: Re: [Resin-interest] Problem with round tripping xml file -encoding response -- Spoke to soon -- I was looking at the wrong output when I said it worked doh! It DOESN'T change anything the symbols are still wrong Rob My code is below public void doPost (HttpServletRequest req, HttpServletResponse res) throws ServletException, IOException { //Set the Output Stream to XML //res.setContentType("application/xml"); res.setContentType("application/xml; charset=UTF-8"); res.setCharacterEncoding("UTF-8"); //set input stream to UTF8 req.setCharacterEncoding("UTF-8"); // Get a handle to the Writer going back to the client PrintWriter out = res.getWriter(); // Get a handle to the Reader coming from the client ServletInputStream in = req.getInputStream(); //create a buffered reader BufferedReader br = new BufferedReader(new InputStreamReader(in)); //Get a text file writer (Can also pass a "File" object) java.io.FileWriter fw = new FileWriter("webapps//ROOT//local//local1.xml"); //create a buffered writer" BufferedWriter bw = new BufferedWriter(fw); try{ String inputLine = null; while ((inputLine = br.readLine()) != null){ bw.write(inputLine+"\r\n"); out.write(inputLine+"\r\n"); } }finally{ bw.close(); out.flush(); out.close(); } } -----Original Message----- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Gary Zhu Sent: Thursday, June 21, 2007 2:13 PM To: 'General Discussion for the Resin application server' Subject: Re: [Resin-interest] Problem with round tripping xml file - encoding response Don't know the other part of your code, but try this: Remove these two lines: res.setContentType("application/xml; charset=UTF-8"); res.setCharacterEncoding("UTF-8"); and put in only: res.setContentType("application/xml"); See what Resin will do... > -----Original Message----- > From: [EMAIL PROTECTED] > [mailto:[EMAIL PROTECTED] Behalf Of Robert Edgar > Sent: Thursday, June 21, 2007 6:59 PM > To: resin-interest@caucho.com > Subject: [Resin-interest] Problem with round tripping xml file - > encoding response > > > I am trying to round trip an xml document that contains some UTF-8 > symbols. > > The doc is constructed on the client (displays correctly). > > It is then posted to the server. > > Server writes the data to a file under ROOT (data is correct) > > Server also writes data back to client as the response. > > Client displays response (data is corrupted - its still a valid xml > but the symbols are no longer correct) > > Client directly requests the file copy of the data from the server > (data display correctly) > > > Server side this is being processed by a servlet, and I have included > the following line at the start of doPost(): > //Set the Output Stream to XML > res.setContentType("application/xml; charset=UTF-8"); > res.setCharacterEncoding("UTF-8"); > //set input stream to UTF8 > req.setCharacterEncoding("UTF-8"); > > I have also added <character-encoding>UTF-8</character-encoding> to > web-app-default configuration file. > > > I am using the latest stable release of Resin(dl yesterday), > standalone, running on my local PC under WinXP. > > I assume the problem has to do with encoding but does anyone know how > to resolve this problem? > > > Thanks > Rob > > > > > _______________________________________________ > resin-interest mailing list > resin-interest@caucho.com > http://maillist.caucho.com/mailman/listinfo/resin-interest > _______________________________________________ resin-interest mailing list resin-interest@caucho.com http://maillist.caucho.com/mailman/listinfo/resin-interest _______________________________________________ resin-interest mailing list resin-interest@caucho.com http://maillist.caucho.com/mailman/listinfo/resin-interest _______________________________________________ resin-interest mailing list resin-interest@caucho.com http://maillist.caucho.com/mailman/listinfo/resin-interest