This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

Bug 138503

Summary: I18N - Cannot create new JSP when <jsp-property-group page-encoding=UTF-16
Product: javaee Reporter: Martin Schovanek <mschovanek>
Component: JSPAssignee: issues@javaee <issues>
Status: RESOLVED WONTFIX    
Severity: blocker CC: jsedek, kfrank
Priority: P3 Keywords: I18N
Version: 6.x   
Hardware: All   
OS: All   
Issue Type: ENHANCEMENT Exception Reporter:

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.
Comment 4 Martin Balin 2016-07-07 08:54:47 UTC
This old bug may not be relevant anymore. If you can still reproduce it in 8.2 development builds please reopen this issue.

Thanks for your cooperation,
NetBeans IDE 8.2 Release Boss