Bug 138503 - I18N - Cannot create new JSP when <jsp-property-group page-encoding=UTF-16
I18N - Cannot create new JSP when <jsp-property-group page-encoding=UTF-16
Status: NEW
Product: javaee
Classification: Unclassified
Component: JSP
6.x
All All
: P3 (vote)
: 6.x
Assigned To: issues@javaee
issues@javaee
: I18N
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2008-06-27 16:49 UTC by Martin Schovanek
Modified: 2014-01-16 10:30 UTC (History)
2 users (show)

See Also:
Issue Type: ENHANCEMENT
:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Martin Schovanek 2008-06-27 16:49:50 UTC
[NB 6.1 FCS + Patch-2, jdk 1.5.0]


to reproduce:
-------------
1) create a new WebProject
2) open web.xml
3) insert before root endtag:
    <jsp-config>
        <jsp-property-group>
            <display-name>All jsp files</display-name>
            <url-pattern>*.jsp</url-pattern>
            <url-pattern>*.jsps</url-pattern>
            <page-encoding>UTF-16</page-encoding>
        </jsp-property-group>
    </jsp-config>
4) create a new .jsp

Q: Do you like Chines Gazette?

ERROR:  You got it.;)
Comment 1 Martin Schovanek 2008-06-27 16:59:03 UTC
Next:
-----
5) modify index.jsp and save it
6) changeet the encoding in web.xml to UTF-8
7) modify index.jsp and save it

ERROR2: 'PWC6330: Page enconding specified in BOM (UTF-16BE) is different from that specified at jsp-property-group.

To fix it you have to delete the BOM outside NetBeans.
Comment 2 Marek Fukala 2008-06-27 17:01:09 UTC
Nasty, but can be workarounded by setting project encoding to UTF-16 as well.

The new template instance apparently uses project encoding but then the page is loaded by the one provided by jsp parser. 

I'll look at it on Monday. Thanks for finding this.
Comment 3 Marek Fukala 2008-07-30 14:07:03 UTC
When a new freemarker template is instancionalized, project ${encoding} is substituted with the project encoding. So if
you create a project with UTF-8 encoding and then create a JSP, the page directive will declare UTF-8.

There is a problem that you can override the <%@page pageEncoding%> directive by the deployment descriptor. Then
according to the JSP specification, if the file doesn't start with BOM then the encoding defined in DD has the highest
precedence and is used.

So we create the file with the project encoding, put the pageEncoding into with the project encoding, but then the file
is loaded by UTF-16 determined by the parser. The same problem happens in runtime if you run the page.

Since the DD can provide various encodings for various file paths, it cannot be fixed by keeping DD encoding == project
encoding.

One possibility is to have a way to choose the file encoding in the new file wizard, or when creating the file from
template, check the DD, find proper url mapping and use the coresponding encoding if there is any.

I am changing this issue to ENHANCEMENT, no time fix it now, it is not P2 defect anyway. 

BTW, as I already written a partial workaround is to set the project encoding to the value specified in DD before
creating the file.


By use of this website, you agree to the NetBeans Policies and Terms of Use. © 2012, Oracle Corporation and/or its affiliates. Sponsored by Oracle logo