Re: Default Charset in Content-Type Header
Alpay Ozturk wrote: Hi, I am using Tomcat 4.1.29 in a production environment and I want tomcat not to add default charset in Content-Type response header. Is it possible? Thanks in advance. Alpay - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] No, it's not possible for text/* types. Tomcat will set a default charset if you don't set it yourself. For jsps you can change the default encoding by overriding it in your web.xml (see conf/web.xml for the defaults). BTW I suspect you might be wanting this because you are trying to set the content type twice: first to text/html (tomcat will set a charset automatically because the servlet spec says text/html should be accompanied by a charset) and then to application/pdf (you end up with content-type: application-pdf; charset=utf-8). We ran into this issue before: you can't get rid of the charset once it is set and you need to set a content-type before you start streaming content. The only thing you might be able to do is to filter the http header with apache or something. Trying to correct this from a servlet filter is tricky because the headers are streamed to the client before the content. The only way to work around this is to wrap the response and buffer the output, set the header in the real response and the stream the buffered content (tomcat will still set a default charset if the type is text/*). The best solution is to simply accept that the charset needs to be set correctly for text/* and to do that yourself. Jilles - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Default Charset in Content-Type Header
You may add the charset of your choice (probably Turkish) to your jsp by adding <%@ page contentType="text/html; charset=iso-8859-9" %> To the beginning of your jsp page. If you do not add this, Tomcat will always default to ISO-8859-1 or UTF-8 (I don't remember which one was default). Regards, Kerem > -Original Message- > From: Alpay Ozturk [mailto:[EMAIL PROTECTED] > Sent: Thursday, September 22, 2005 12:37 PM > To: Tomcat Users List > Subject: Default Charset in Content-Type Header > > Hi, > > I am using Tomcat 4.1.29 in a production environment and I > want tomcat > not to add default charset in Content-Type response header. > Is it possible? > > Thanks in advance. > > Alpay > smime.p7s Description: S/MIME cryptographic signature
RE: Default Charset in Content-Type Header
Thanks Kerem , But I need to set the content-type of a servlet response as "application/vnd.wap.mms-message" without adding a charset header. Since some handsets do not accept the MMS response messages although the messsage is well-encoded. Anyway, thanks for your response. Regards, Alpay On Thu, 2005-09-22 at 13:51, KEREM ERKAN wrote: > You may add the charset of your choice (probably Turkish) to your jsp by > adding > > <%@ page contentType="text/html; charset=iso-8859-9" %> > > To the beginning of your jsp page. If you do not add this, Tomcat will > always default to ISO-8859-1 or UTF-8 (I don't remember which one was > default). > > Regards, > > Kerem > > > > -Original Message- > > From: Alpay Ozturk [mailto:[EMAIL PROTECTED] > > Sent: Thursday, September 22, 2005 12:37 PM > > To: Tomcat Users List > > Subject: Default Charset in Content-Type Header > > > > Hi, > > > > I am using Tomcat 4.1.29 in a production environment and I > > want tomcat > > not to add default charset in Content-Type response header. > > Is it possible? > > > > Thanks in advance. > > > > Alpay > > - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Default Charset in Content-Type Header
Thanks Jilles , I need to set the content-type of a servlet response as "application/vnd.wap.mms-message". But I will recheck my code if I am setting content-type to text/html before setting it to "application/vnd.wap.mms-message". If it does not work, I will wrap the response as you suggested. Thanks for your response and suggestions. Regards, Alpay On Thu, 2005-09-22 at 14:08, Jilles van Gurp wrote: > Alpay Ozturk wrote: > > Hi, > > > > I am using Tomcat 4.1.29 in a production environment and I want tomcat > > not to add default charset in Content-Type response header. > > Is it possible? > > > > Thanks in advance. > > > > Alpay > > > > > > - > > To unsubscribe, e-mail: [EMAIL PROTECTED] > > For additional commands, e-mail: [EMAIL PROTECTED] > > > > > > > > > No, it's not possible for text/* types. Tomcat will set a default > charset if you don't set it yourself. For jsps you can change the > default encoding by overriding it in your web.xml (see conf/web.xml for > the defaults). > > BTW I suspect you might be wanting this because you are trying to set > the content type twice: first to text/html (tomcat will set a charset > automatically because the servlet spec says text/html should be > accompanied by a charset) and then to application/pdf (you end up with > content-type: application-pdf; charset=utf-8). We ran into this issue > before: you can't get rid of the charset once it is set and you need to > set a content-type before you start streaming content. > > The only thing you might be able to do is to filter the http header with > apache or something. Trying to correct this from a servlet filter is > tricky because the headers are streamed to the client before the > content. The only way to work around this is to wrap the response and > buffer the output, set the header in the real response and the stream > the buffered content (tomcat will still set a default charset if the > type is text/*). > > The best solution is to simply accept that the charset needs to be set > correctly for text/* and to do that yourself. > > Jilles > > - > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Default Charset in Content-Type Header
Return binary content from a servlet using the ServletOutputStream and you should have no problem. This is the way we vend MMS data. (In fact all of our binary data.) HTH, Jon Alpay Ozturk wrote: Thanks Kerem , But I need to set the content-type of a servlet response as "application/vnd.wap.mms-message" without adding a charset header. Since some handsets do not accept the MMS response messages although the messsage is well-encoded. Anyway, thanks for your response. Regards, Alpay On Thu, 2005-09-22 at 13:51, KEREM ERKAN wrote: You may add the charset of your choice (probably Turkish) to your jsp by adding <%@ page contentType="text/html; charset=iso-8859-9" %> To the beginning of your jsp page. If you do not add this, Tomcat will always default to ISO-8859-1 or UTF-8 (I don't remember which one was default). Regards, Kerem -Original Message- From: Alpay Ozturk [mailto:[EMAIL PROTECTED] Sent: Thursday, September 22, 2005 12:37 PM To: Tomcat Users List Subject: Default Charset in Content-Type Header Hi, I am using Tomcat 4.1.29 in a production environment and I want tomcat not to add default charset in Content-Type response header. Is it possible? Thanks in advance. Alpay - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]