Re: [jetty-user] Why iso-8859-1 is added to response header by default?
Joakim Erdfelt <[email protected]>
| Newsgroups | gmane.comp.java.jetty.support |
|---|---|
| Message-ID | <[email protected]> |
I suspect this is a remnant of Servlet spec days gone past.
For example, if using response.getOutputStream() to send text, it can *only*
be ISO-8859-1 encoded.
This is a hard and fast rule with the servlet spec.
http://grepcode.com/file/repo1.maven.org/maven2/javax.servlet/servlet-api/2.4/javax/servlet/ServletOutputStream.java
I suspect that if Jetty detects use of response.getOutputStream() it
enforces this rule.
Now, this appears to suck, however, you have to understand that
response.getOutputStream() is really only for binary data.
If you want to use a different content-type encoding charset, then you'll
have to use the writers instead, along with setting the response headers you
want.
response.setContentType("text/html; charset=UTF-8");
response.setCharacterEncoding("UTF-8");
PrintWriter writer = response.getWriter();
writer.print(some UTF-8 content);
- Joakim
On Wed, Oct 27, 2010 at 2:12 AM, t h <[email protected]> wrote:
> Hi,
> I cannot understand why jetty add default charset to Content-Type when
> no charset is specified.
> Modern browser can detect encoding by reading <meta> tag in body.
> So I think no charset should be set when no charset is specified.
> What do you think?
>
> Thanks.
>
> --
> Takahiro Hozumi
>
> ---------------------------------------------------------------------
> To unsubscribe from this list, please visit:
>
> http://xircles.codehaus.org/manage_email
>
>
>