Hi, You're barking up the wrong (but only slightly wrong) tree. Instead of messing with the charset stuff, make sure to set a content-disposition header on your response. Google for it if you're not sure what it is: it's simple and there are tons of examples online. This is the only way to ensure somewhat consistent behavior across browsers for this use-case.
Yoav Shapira http://www.yoavshapira.com >-----Original Message----- >From: Mathias Payer [mailto:[EMAIL PROTECTED] >Sent: Wednesday, November 03, 2004 12:20 PM >To: [EMAIL PROTECTED] >Subject: Problem with Tomcat 4.1 & Charset > >Hi List! > >I've got a big problem to solve. > >On a windows server I installed an acutal jsdk and tomcat 4.1. >Now I developed a jsp-Servlet that sets it's content-type to >"application/pdf" and only writes pdf-data out. > >If I run this on my testserver with tomcat 4.0 (debian/linux) everything >runs fine and Internet Explorer is able to open the pdf. > >But if I merge to the production server (tomcat 4.1/win 2k3) (<- not my >choice :) ) and try to acces the exact same page I get a funny error! > >Internet Explorer tells me to save the file to disc! > >It took me a long time to figure out that the only difference is in the >headers! > >=> The Linux Machine wirtes: Content-Type: application/pdf >=> The Windows Machine wirtes: C ontent-Type: >application/pdf;charset=ISO-8859-1 > >Because of this additional charset Internet Explorer is no longer able >to start the pdf-Viewer and display the file inline. > >Attached are some snips from the code: > >--SNIP-- > // response.setHeader("Content-disposition","inline; >filename=generated.pdf"); // response.setHeader("Pragma", >"no-cache"); // response.setHeader("Cache-Control", "no-cache"); > // response.setHeader("Cache-Control","no-store" ); > // response.setDateHeader("Expires", -1); > // response.setHeader("Content-Type","application/pdf" ); > response.setContentType( "application/pdf" ); > --SNAP-- >This shows some different options I tried -> Somewhere on the web it was >mentioned that IE had problems with caches and so on... The second last >line resulted in two Content-Type headers, but I set the Content-Type >nowhere else in the JSP! > >--SNIP-- > ByteArrayOutputStream buffer = new ByteArrayOutputStream(); > ... > // we output the writer as bytes to the response output > response.setContentLength(buffer.size()); > ServletOutputStream output = response.getOutputStream(); > buffer.writeTo(output); > output.flush(); >--SNAP-- >buffer is my byte-buffer where the raw pdf resides. > >Can somebody help me how I can disable or suppress this charset-stuff? > >Or if you have some ideas, just mention them! > >Thanks in advance! >Greats >Mathias > >-- >Homepage: http://cgi.ethz.ch/~payerm/ GPG-Keys unter Privat/Kontakt This e-mail, including any attachments, is a confidential business communication, and may contain information that is confidential, proprietary and/or privileged. This e-mail is intended only for the individual(s) to whom it is addressed, and may not be saved, copied, printed, disclosed or used by anyone else. If you are not the(an) intended recipient, please immediately delete this e-mail from your computer system and notify the sender. Thank you. --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
