dev@glassfish.java.net

Re: encoding in JSP Documents - JDK6 I18N Issue??

From: Krishnamohan Meduri <Krishna.Meduri_at_Sun.COM>
Date: Tue, 07 Nov 2006 11:04:17 -0800

Jan,


Jan Luehe wrote On 11/06/06 18:26,:
> Krishna,
>
> Krishnamohan Meduri wrote On 11/06/06 17:23,:
>
>
>>Hi,
>>
>>Glassfish with JDK6 produces undesired results (with some characters
>>messed up) for the attached JSP Document.
>>The same produces the desired results with JDK5.
>>
>>Is this any known issue in JDK6? If so, Could somebody pls give me the
>>details?
>>
>>
>
>
> No details, but here's a related issue:
>
> http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6473140
> ("getCharacterEncoding() did not return the default-charset on
> windows2003(JDK 6, AS90PE)")
>
> that was filed against GlassFish.
>
> I've done some initial investigation, and it looks like creating a
> String, using the String constructor that takes a charsetName, throws
> an UnsupportedEncodingException when specifying "Shift_JIS" as the
> encoding on Windows (we use the String constructor that takes a
> charsetName argument as a test to see if the encoding passed to
> ServletRequest.setCharacterEncoding() is valid and supported by the
> runtime). I've asked the submitter to confirm.
>
> Do you see any UnsupportedEncodingException in your server log? Also,
> do you see this problem on Windows only?

This appears to be a different problem.
I *don't* see any exception. I can see the problem on Glassfish on
*Solaris* also.
To reproduce, all you need to do is have this JSP document in a web app
and send a request to it. While switching JDK version, just make sure
that you remove generated classes from generated folder.
On glassfish, I got the output attached (jdk5.out.as and jdk6.out.as).
I took out just oneline (1st line from 2nd para) from both the files and
ran xxd. I attached the output. As you can see, a few characters are
getting messed up.

I wanted to know if it is any known JDK6 issue before I start debugging.

-Krishna.
>
>
> Jan
>
>
>
>>Thanks,
>>-Krishna.
>>
>>
>>------------------------------------------------------------------------
>>
>><?xml version="1.0" encoding="big5"?>
>><!--
>> @author James Cai, for I18N feature in JSP 2.0 in XML
>>
>> Configuration as the following:
>> Syntax pageEncoding contentType XML-prolog
>> XML big5 gb2312 -
>>-->
>>
>><jsp:root xmlns:jsp="http://java.sun.com/JSP/Page"
>>version="2.0">
>><jsp:directive.page contentType="text/html; charset=gb2312" />
>><jsp:text><![CDATA[<HTML>
>><HEAD>
>> <TITLE>I18N TEST JSP2.0</TITLE>
>></HEAD>
>>
>><BODY>
>>
>><FONT SIZE='+3'>
>>
>><CENTER>
>>
>><BR/>
>>
>>
>><H1>Test Name: XML8-gb </H1>
>>
>><BR/>
>><BR/>
>><TABLE BORDER='1'>
>><TR><TH>Language</TH><TH>Charset</TH></TR>
>><TR><TD>Chinese</TD><TD>gb2312</TD></TR>
>></TABLE>
>>
>><BR/>
>>
>>The following is Chinese character with gb2312 charset:
>>
>><BR/><BR/>
>>
>>京报网讯(记者 丁肇文)从今天开始,美国麻省理工学院斯隆管理学院与清华大学经管学院、复旦大学管理学院、香港岭南大学
>> 为合作培养国际MBA,在香港召开顾问委员会会议。记者昨天从清华大学获悉,作为各自国家最顶尖的商学院之一的清华大学
>> 经管学院与麻省理工学院斯隆管理学院,在圆满完成了第一个五年周期的合作之后,已经决定从今年起续签五年的合作项目,双方
>> 从1500名申请者中选拔出的新一批120名合作培养的国际MBA学员,即将于今年9月进清华大学。
>>
>> 清华大学经管学院院长赵纯均昨天在接受记者采访时表示,清华自1996年与麻省理工合作以来,至今已培养了三期共100余名国
>> 际MBA学员,这些毕业学员一般都去了国内外的跨国企业和组织,一直供不应求,有的在短短两三年内,就已经坐到了CEO
>> 的位置;在合作期间,清华先后派出20余名教师,在斯隆经济管理学院学习。赵纯均院长还透露,在过去的合作中,清华方面的主
>> 要精力集中在了必修课的建设方面,在第二个五年的合作中,放在选修课方面的精力会多一些。同时,这种类似于技术转让的模
>> 式,在经历了五年的合作后已经实现了将国外成熟的MBA培养模式移植到国内的目标。
>>
>> 昨天专程到北京参加清华2001届国际MBA毕业典礼的斯隆管理学院前任院长、著名国际经济学家斯若教授也认为双方前五年
>> 的合作非常成功,他曾经通过视频会议的方式“面对面”地为清华国际MBA学员授过课,他认为中国的国际MBA项目以及培
>> 养出的学员都不比美国差,惟一的缺点在于学生的成分缺乏国际性,在美国大约40%的学员来自于其他不同的国家,而在中国几乎
>> 是清一色的国内学员。
>>
>></CENTER>
>><BR/>
>><BR/>
>>]]></jsp:text>
>><jsp:text>CharacterEncoding:
>></jsp:text>
>><jsp:expression>response.getCharacterEncoding()</jsp:expression>
>><jsp:text>&lt;BR/&gt;</jsp:text>
>><jsp:text><![CDATA[
>></body>
>></html>
>>]]></jsp:text>
>></jsp:root>
>>
>>
>>------------------------------------------------------------------------
>>
>>---------------------------------------------------------------------
>>To unsubscribe, e-mail: dev-unsubscribe_at_glassfish.dev.java.net
>>For additional commands, e-mail: dev-help_at_glassfish.dev.java.net
>>
>>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe_at_glassfish.dev.java.net
> For additional commands, e-mail: dev-help_at_glassfish.dev.java.net
>


Trying 127.0.0.1...
Connected to localhost.
Escape character is '^]'.
HTTP/1.1 200 OK
X-Powered-By: JSP/2.1
Set-Cookie: JSESSIONID=fd795e713596e06cc9d6dcca9f0e; Path=/i18n
Content-Type: text/html;charset=gb2312
Content-Length: 1683
Date: Tue, 07 Nov 2006 00:35:46 GMT
Server: Sun Java System Application Server Enterprise Edition 9.1
Connection: close

<HTML>
<HEAD>
   <TITLE>I18N TEST JSP2.0</TITLE>
</HEAD>

<BODY>

<FONT SIZE='+3'>

<CENTER>

<BR/>


<H1>Test Name: XML8-gb </H1>

<BR/>
<BR/>
<TABLE BORDER='1'>
<TR><TH>Language</TH><TH>Charset</TH></TR>
<TR><TD>Chinese</TD><TD>gb2312</TD></TR>
</TABLE>

<BR/>

The following is Chinese character with gb2312 charset:

<BR/><BR/>

?惆?捅ㄗ暮氪??欷?ㄘ植踏?羲?ㄛ?弊????悝埏佴???悝埏?ь貌湮悝??悝埏?葩筒湮悝??悝埏?????湮悝
                        ?磁???弊?MBAㄛ????羲嘈?????祜?暮氪??植ь貌湮悝??ㄛ??跪?弊模???腔?悝埏??腔ь貌湮悝
                        ??悝埏?????悝埏佴???悝埏ㄛ?埴??????跺???ぶ腔磁???ㄛ??樵隅植踏?れ哿ワ??腔磁??醴ㄛ?源
                        植1500靡?③氪?恁匿堤腔陔??120靡磁???腔弊?MBA悝?ㄛ?蔚衾踏?9??ь貌湮悝?

                        ь貌湮悝??悝埏埏酗?曾歙?????暮氪粒??桶?ㄛь貌?1996??????磁??懂ㄛ?踏??????ぶ?100?靡弊
                        ?MBA悝?ㄛ??救?悝??啜??民佴???腔?弊わ?睿??ㄛ??鼎祥茼⑴ㄛ衄腔?傻傻?????ㄛ憩???善?CEO
                        腔?离??磁?ぶ?ㄛь貌珂??堤20?靡??ㄛ?佴?????悝埏悝???曾歙埏酗???ㄛ???扔????甭?疝????
                        猁?薯摩???斛党?腔膘?源?ㄛ???跺??腔磁??ㄛ??恁党?源?腔?薯?嗣???肮?ㄛ?笱?侔衾撮??????
                        ?ㄛ??????腔磁????妗??蔚弊???腔MBA??耀?痄眵善弊?腔醴梓?

                        ???最善控???ь貌2001趣弊?MBA救?萎?腔佴???悝埏ヶ??熙丑H躞?弊???悝模佴??昃?笮???褒匿??
                        腔磁??都?髡ㄛ坻?????け?祜腔源?※?勤?§??ь貌弊?MBA悝????ㄛ坻??肯??腔弊?MBA?醴???
                        ?堤腔悝??祥掀?弊船ㄛ??腔?接???床?腔?煦?捧此???ㄛ??弊湮?40ㄔ腔悝?懂?衾む坻祥肮腔弊模ㄛ???弊??
                        ?ь?伎腔弊?悝??

</CENTER>
<BR/>
<BR/>
CharacterEncoding:
gb2312<BR/>
</body>
</html>
Connection to localhost closed by foreign host.

Trying 127.0.0.1...
Connected to localhost.
Escape character is '^]'.
HTTP/1.1 200 OK
X-Powered-By: JSP/2.1
Set-Cookie: JSESSIONID=ff5f3f1b612f80532e8eadfa11e8; Path=/i18n
Content-Type: text/html;charset=gb2312
Content-Length: 1678
Date: Tue, 07 Nov 2006 01:08:57 GMT
Server: Sun Java System Application Server Enterprise Edition 9.1
Connection: close

<HTML>
<HEAD>
   <TITLE>I18N TEST JSP2.0</TITLE>
</HEAD>

<BODY>

<FONT SIZE='+3'>

<CENTER>

<BR/>


<H1>Test Name: XML8-gb </H1>

<BR/>
<BR/>
<TABLE BORDER='1'>
<TR><TH>Language</TH><TH>Charset</TH></TR>
<TR><TD>Chinese</TD><TD>gb2312</TD></TR>
</TABLE>

<BR/>

The following is Chinese character with gb2312 charset:

<BR/><BR/>

?惆?捅ㄗ暮氪??欷?ㄘ植踏?羲?ㄛ?弊????悝埏佴???悝埏?ь貌湮悝??悝埏?葩筒湮悝??悝埏?????湮悝
                        ?磁???弊?MBAㄛ????羲嘈?????祜?暮氪??植ь貌湮悝??ㄛ??跪?弊模???腔?悝埏??腔ь貌湮悝
                        ??悝埏?????悝埏佴???悝埏ㄛ?埴??????跺???ぶ腔磁???ㄛ??樵隅植踏?れ哿ワ??腔磁??醴ㄛ?源
                        植1500靡?③氪?恁匿堤腔陔??120靡磁???腔弊?MBA悝?ㄛ?蔚衾踏?9??ь貌湮悝?

                        ь貌湮悝??悝埏埏酗?曾歙?????暮氪粒??桶?ㄛь貌?1996??????磁??懂ㄛ?踏?????ぶ?100?靡弊
                        ?MBA悝?ㄛ??救?悝??啜???弊??腔?弊わ?睿??ㄛ??鼎祥茼⑴ㄛ衄腔?傻傻????ㄛ憩???善?CEO
                        腔?离??磁?ぶ?ㄛь貌珂??堤20?靡??ㄛ?佴?????悝埏悝???曾歙埏酗???ㄛ???腔磁??ㄛь貌源?腔?
                        猁?薯摩???斛党?腔膘?源?ㄛ???跺??腔磁??ㄛ??恁党?源?腔?薯?嗣???肮?ㄛ?笱?侔衾撮???腔耀
                        ?ㄛ??????腔磁????妗??蔚弊???腔MBA??耀?痄眵善弊?腔醴梓?

                        ???最善控???ь貌2001趣弊?MBA救?萎?腔佴???悝埏ヶ?埏酗??靡弊???悝模佴???珩???源ヶ??
                        腔磁??都?髡ㄛ坻?????け?祜腔源?※?勤?§??ь貌弊?MBA悝????ㄛ坻???弊腔弊?MBA?醴???
                        ?堤腔悝??祥掀?弊船ㄛ??腔?萸?衾悝汜腔?煦?椰弊??ㄛ??弊湮?40ㄔ腔悝?懂?衾む坻祥肮腔弊模ㄛ???弊??
                        ?ь?伎腔弊?悝??

</CENTER>
<BR/>
<BR/>
CharacterEncoding:
gb2312<BR/>
</body>
</html>
Connection to localhost closed by foreign host.

0000000: a7ee c3b2 e4ce e3a6 3f3f e3a6 dbef dbef ........??......
0000010: d0ef 3fd4 f8ec a83f 3f3f 3f3f c4ba ebb4 ..?....?????....
0000020: c1a3 3f3f cdb0 3fa8 dba7 eec3 b23f 3139 ..??..?......?19
0000030: 3936 3f3f 3f3f 3f3f b4c5 3f3f b6ae a8db 96??????..??....
0000040: 3fcc a43f 3f3f 3f3f 3fa4 d63f 3130 303f ?..??????..?100?
0000050: c3d2 b1d7 0a .....


0000000: a7ee c3b2 e4ce e3a6 3f3f e3a6 dbef dbef ........??......
0000010: d0ef 3fd4 f8ec a83f 3f3f 3f3f c4ba ebb4 ..?....?????....
0000020: c1a3 3f3f cdb0 3fa8 dba7 eec3 b23f 3139 ..??..?......?19
0000030: 3936 3f3f 3f3f 3f3f b4c5 3f3f b6ae a8db 96??????..??....
0000040: 3fcc a43f 3f3f 3f3f a4d6 3f31 3030 3fc3 ?..?????..?100?.
0000050: d2b1 d70a ....