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.
The JSP data object should provide or at least use FileEncodingQuery to read store in correct encoding. The best solution is not to overide loadStreamToKit and saveKitToStream and provide implementation of the FileEncodingQueryImplementation which detects an encoding inside the JSP file when available. This allows not only editor but all other features like search and other which works directly on FileObject level to read the file in the correct encoding. The minimal change for NB 6.0 should be to use FEQ in case when no encoding has been found in the loadFromStreamToKit or saveFromKitToStream. (When no encoding is inside the HTML file the project encoding should be used.)
I have a patch ready for FileEncodingQuery functionality. It removes loadStreamToKit and saveKitToStream overrides and relies on the FileEncodingQuery implementation completely. The correct encoding is determined as follows: 1. When a JSP is being loaded the "ENCODING" FileObject property is consulted for the encoding - JSP content analysis can not be used because it causes infinite loop (for finding out the encoding the JSP needs to be loaded what in turn results in request for the correct encoding and so on and so forth) 2. Upon save the encoding derived from all possible source (encoding tag, JSP property group, include-prelude etc.) is propagated to the "ENCODING" property. The only downside is that modifying any part needed to resolve the correct encoding outside of NB can result into loading the JSP with incorrect encoding. Any comments welcome
if jsp charset notes an encoding different from project encoding, which one is used ? or is it that the jsp charset tag is for runtime only and does not impact view of encoding used by working in jsp editor, etc ? ken.frank@sun.com
The encoding used while editing JSP mimics the encoding to be used in runtime. The implication of this is the fact that for a JSP file the project defined encoding is ignored.
Fixed using the proposed implementation Checking in nbproject/project.xml; /cvs/web/core/nbproject/project.xml,v <-- project.xml new revision: 1.27; previous revision: 1.26 done Checking in src/org/netbeans/modules/web/core/jsploader/BaseJspEditorSupport.java; /cvs/web/core/src/org/netbeans/modules/web/core/jsploader/BaseJspEditorSupport.java,v <-- BaseJspEditorSupport.java new revision: 1.59; previous revision: 1.58 done Checking in src/org/netbeans/modules/web/core/jsploader/JspNode.java; /cvs/web/core/src/org/netbeans/modules/web/core/jsploader/JspNode.java,v <-- JspNode.java new revision: 1.31; previous revision: 1.30 done Checking in src/org/netbeans/modules/web/core/jsploader/JspDataObject.java; /cvs/web/core/src/org/netbeans/modules/web/core/jsploader/JspDataObject.java,v <-- JspDataObject.java new revision: 1.65; previous revision: 1.64
The fix probably caused that a warning dialog appears when you create a web project and it opens index.jsp file. Message is: The "ISO-8559-1" character set that is used in index.jsp is not a valid character set for JSP Pages. Do you want to open the file using the UTF-8 character set? Please, fix it ASAP. It breaks automated tests. Thanks.
sorry for that this will fix it Checking in JspDataObject.java; /cvs/web/core/src/org/netbeans/modules/web/core/jsploader/JspDataObject.java,v <-- JspDataObject.java new revision: 1.66; previous revision: 1.65 done Checking in JspLoader.java; /cvs/web/core/src/org/netbeans/modules/web/core/jsploader/JspLoader.java,v <-- JspLoader.java new revision: 1.24; previous revision: 1.23 done
*** Issue 106004 has been marked as a duplicate of this issue. ***
does the fix work as per info I'd gotten from Peter ? I want to be clear so can then verify it. this is for already created jsp files - if encoding tag exists, it is used instead of project encoding - if no encoding tag In the jsp case, if there is not an encoding mentioned in the file, it doesn't mean that the the project encoding should be used. The file object feq is implemented according jsp specification, so in such case the encoding can be mentioned in the web.xml or in a preloaded jsp file. If there is not defined encoding for a jsp file then according jsp specification the default encoding is iso-8859-1. So the jsp file object feq always returns an encoding, even if is not defined (the iso-8859-1) and the project encoding will be never used for jsp files. ken.frank@sun.com
yes, exactly. the resolution of FE for JSP is delegated to the TagLibParseSupport class which does all the magic - handles encoding tags, encoding definitions in web.xml, preludes etc. it should also handle the correct default encoding if there is none specified.