On Monday 22 July 2002 23:26, Dmitry Melekhov wrote:
> Eric Leung wrote:
> > Hi,
> >
> > yes, just like HTML add a line like this:
> > <META HTTP-EQUIV="Content-Type" Content="text/html; Charset=iso-8859-1">
> >
> > ^^^^^^^^^^^^
> >
> > character set
> >
> > Eric
>
> I understand.
> But our devepopers are too lazy ;-)
> They don't want to write this line in every jsp...
> Is it possible to configure Tomcat (something else) to set default
> encoding?
Besides that, the meta tag doesn't quite work.
Tomcat outputs:
Content-Type: text/html; charset=iso-8859-1
As one of its standard headers. So, if you're like us, and you're trying to
output Simplified Chinese, the Simplified Chinese will still show up as
garbage characters. The meta tag only overrode the http response header
under Mozilla, and only under certain conditions.
To get around this problem, you can change your page directive to be:
<%@page contentType="text/html"%>
Note, how I didn't include the charset as part of the content type.
The default is:
<%@page contentType="text/html; charset=iso-8559-1"%>
So, what you can do is:
<%@page contentType="text/html"%>
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=gb2312" />
<meta http-equiv="language" content="zh_CN" />
</head>
<body>This is my ���� text.</body>
</html>
And if you've got lazy programmers, you can always write a perl script to go
through every page that's already been written and just insert it. Every
subsequent page however, will need to be updated manually. Or, like I
did...a combination of perl and shell scripts :) I had the task of updating
400 JSP files, and there was no damned way I was going to do it manually. :p
If you'd like, you can email me privately, and I'll send you the perl utility
I used as a base for my scripts, but the shell scripts are heavily site
dependent.
ttfn
--
To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>