tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Antonio Fiol BonnĂ­n <fiol.bon...@terra.es>
Subject Re: pageEncoing and contentType
Date Tue, 20 Apr 2004 05:54:14 GMT
What are you using to make the PDF content slip into the wire?

If you are using a "Writer" you get from response.getWriter(), you may 
have interest in trying to use the "OutputStream", as in 
response.getOutputStream().

This is what the description of the getWriter method says: Returns a 
print writer for writing formatted text responses. The MIME type of the 
response will be modified, if necessary, to reflect the character 
encoding used, through the /charset=.../ property. This means that the 
content type must be set before calling this method.

So don't use it for binary things...


Antonio Fiol


seiji takegata wrote:

>Hi Veniamin,
>Thank you for your reply.
>
>  
>
>>    What it means "character is not encoded correctly"? If PDF content 
>>is unreadable, then that's PDF file problem, not Tomcat. Is this PDF 
>>opens correctly by itself, i.e. when you open it through Adobe Reader?
>>    Anyway, just do response.setContentType("application/pdf") and let 
>>browser open it accordingly.
>>
>>    
>>
>
>I tried. Then Japanese characters are all dimed (converted to 
>randome characters like noise). 
>
>Because itext asumes Japanese character as Shift_JIS encoded, 
>but Tomcat default is UTF-8, so I have to specify pageEncoding 
>attribute in page directive.
>
>I can see PDF content is correct when I save it as a file and
>open with Adobe Reader.
>
>My point is why tomcat put charset option to contentType when I 
>specify pageEncoding attribute. I might write code to generate
>image from String, then the content should not be attributed
>like "charset=Shift_JIS". but still I need to specify 
>pageEncoding attribute for correct character encoding.
>
>I just want tomcat to stop adding charset option when 
>pageEncoding attribute is specified.
>
>Am I wrong?
>
>  
>
>>seiji takegata wrote:
>>
>>    
>>
>>>I'm trying to generate PDF document directory from JSP using 
>>>itext library. I have an encoding problem.
>>>
>>>I put pageEncoding and contentType attributes in page directive 
>>>as:
>>>
>>><%@ page contentType="application/pdf"%>
>>><%@ page pageEncoding="Shift_JIS"%>
>>>
>>>Then tomcat (or jasper) translates them like:
>>>
>>>response.setContentType("application/pdf;charset=Shift_JIS");
>>>
>>>IE will not open AdobeReader, show download dialog instead.
>>>
>>>If I do not specify pageEncoding, then the line above will be:
>>>
>>>response.setContentType("application/pdf");
>>>
>>>AdobeReader opens as I expect. But character is not encoded 
>>>correctory.
>>>
>>>I wonder why "charset=Shift_JIS" is added to contentType string.
>>>I want remove it from the contentType string, or remove whole 
>>>the line. I think I can specify contentType by 
>>>
>>>response.setCotentType("application/pdf");
>>>      
>>>
>>
>>    
>>
>--
>seiji takegata
>takegata@veltec.co.jp
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
>For additional commands, e-mail: tomcat-user-help@jakarta.apache.org
>
>
>  
>


Mime
View raw message