RE: JSP containers and default charset (was: Re DefaultCharset considered harmful)

On Sun, 30 Nov 2003, Addison Phillips [wM] wrote:

Hi Addison,

> I think you're forgetting what happens to a JSP page. You can't just have
> the JSP container omit to mention the charset in the HTTP header because the
> encoding is important in the lifecycle of a JSP page: JSP pages are compiled
> into servlets. That is, they are turned into a small Java program that

You're absolutely right.  Therefore, the charset declaration in a JSP
file serves dual purposes. It indicates the character encoding of the
JSP file to the Java compiler (i.e. playing the same role as '-encoding'
option when invoking 'javac') and it also indicates in what character
encoding the generated html file should be served to the outside world.
Someone might argue that there need to be two separate 'directives' for
two roles, but I guess it's all right to overload pageEncoding directive.


> servlet (i.e. those String objects) to begin with. Parsing the HTML to look
> for a META tag is not a really reliable solution. So unless the file is

 Yup, I can't agree with you more.

> encoding, including UTF-8, wouldn't really solve the problem: people want to
> use legacy encodings from time to time as well. Setting the page encoding
> and content type should just be automatically part of what a JSP developer
> does in every page.

  I was labelling ASCII only files as UTF-8, which is why I didn't
realize that when I wrote the message.

  Thanks,

  Jungshik

Received on Sunday, 30 November 2003 21:11:24 UTC