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 179585 - Jsp tag file encoding is forced to be ISO-8859-1 for maven project type "bundle"
Summary: Jsp tag file encoding is forced to be ISO-8859-1 for maven project type "bundle"
Status: NEW
Alias: None
Product: javaee
Classification: Unclassified
Component: JSP (show other bugs)
Version: 6.x
Hardware: Other Linux
: P3 normal with 3 votes (vote)
Assignee: issues@javaee
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-01-16 12:20 UTC by benderamp
Modified: 2016-03-30 15:16 UTC (History)
3 users (show)

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments
Screenshot of ignored encoding set in tag file (29.46 KB, image/png)
2010-08-27 08:06 UTC, lenniboy
Details

Note You need to log in before you can comment on or make changes to this bug.
Description benderamp 2010-01-16 12:20:29 UTC
1. Create new Maven Web Application Project
2. Create new jsp tag file (would go to WEB-INF/tags directory)
3. Open it in the editor, rightclick and select properties to make sure it has encoding "UTF-8"
4. Open pom.xml file and change project type (packaging tag value) to "bundle"
5. Close tag file and open it again in the editor (important - just selecting its properties in the project tree will not work)

Result:
See that now it has encoding "ISO-8859-1" and if it had some non-latin characters inside, they woul be displayed incorrectly in the editor.

Expected result:
Encoding for tag files should remain UTF-8 with any project type.

This magically happens only with jsp tag files - other jsp and java files are not affected. Changing project type back to "war" brings back the right UTF-8 encoding.
Comment 1 Milos Kleint 2010-01-18 00:27:34 UTC
reassigning to javaee. Having files not respecting the project's encoding settings sounds like a bug in the jsp dataloader (or whereever the encoding is set)
Comment 2 Petr Jiricka 2010-01-20 04:05:33 UTC
Actually, the IDE has to honor the encoding that will be used at runtime. The JSP spec clearly says how to determine the encoding, and the server needs to honor that. The IDE must use the same algorithm as the server. 

By default, JSP encoding is ISO-8859-1 if not overriden, which is the reason why a JSP page created from template in NetBeans overrides this default:

<%@page contentType="text/html" pageEncoding="UTF-8"%>

The JSP specification of course specifies the algorithm to determine the encoding in the context of a war file, which is the standard packaging format for web applications. It takes into account web.xml etc. Now we are dealing with a non-standard packaging format (OSGi bundle - see also discussion in bug 179584), so how do we determine the encoding if it is not specified? How does the server do it?

Regarding your tag file, does it specify the pageEncoding attribute in the page directive?
Comment 3 benderamp 2010-01-21 02:28:06 UTC
I have made some experiments with jsp and tag files.

Both normal jsp and jsp tag have "pageEncoding="UTF-8"" in the header (which is added by default):

<%@tag description="put the tag description here" pageEncoding="UTF-8"%>


1. For war project + pageEncoding="UTF-8" in the header:
- .jsp file has UTF-8 encoding
- .tag file has UTF-8 encoding

2. For bundle project + pageEncoding="UTF-8" in the header:
- .jsp file has UTF-8 encoding
- .tag file has ISO-8859-1 encoding

3. For war project + pageEncoding not set in the header:
- .jsp file has ISO-8859-1 encoding
- .tag file has ISO-8859-1 encoding

4. For bundle project + pageEncoding not set in the header:
- .jsp file has ISO-8859-1 encoding
- .tag file has ISO-8859-1 encoding


So, for jsp files pageEncoding value is respected with no dependance to project type, for tag files it is respected only for war projects.
Comment 4 Petr Jiricka 2010-01-21 02:50:41 UTC
Thanks for investigating. Assigning to Tomasz.
Comment 5 lenniboy 2010-08-27 08:06:42 UTC
Created attachment 101710 [details]
Screenshot of ignored encoding set in tag file
Comment 6 lenniboy 2010-08-27 08:10:53 UTC
I have just hit this bug (?) too. 

I'm using the JAR project type and for love nor money does Netbeans open my tag files in UTF-8.

I have set the -J-Dfile.encoding=UTF-8 flag in netbeans.conf, the project's encoding is set to UTF-8, too, and the tag file has both an XML doctype and a pageEncoding directive both specifying UTF-8 as the encoding.

I would love to create a path and I'm currently checking out the sources. Judging from the download time, the project is vast and I would appreciate any pointers of where to look.

Thanks.
Comment 7 lenniboy 2010-08-27 08:58:10 UTC
> I would love to create a path and I'm currently checking out the sources.

*patch* not path.
Comment 8 asxtray 2014-11-06 09:23:04 UTC
Same thing even with WAR (8.0.1)
Comment 9 coladict 2014-12-05 12:45:54 UTC
I found a new way to reproduce this encoding detection problem.

Have a jsp file encoded in UTF-8 and simply change the file extension to jspf.
Instantly it becomes treated as a ISO-8859-1 and all non-ascii symbols become unreadable.

Adding -J-Dfile.encoding=UTF-8 to the launch options did not help.