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 138312 - I18N - Error in JSP Editor(svn diff view)
Summary: I18N - Error in JSP Editor(svn diff view)
Status: VERIFIED FIXED
Alias: None
Product: versioncontrol
Classification: Unclassified
Component: Code (show other bugs)
Version: 6.x
Hardware: All Windows XP
: P2 blocker (vote)
Assignee: Tomas Stupka
URL:
Keywords: I18N
Depends on:
Blocks:
 
Reported: 2008-06-26 08:25 UTC by vigor
Modified: 2008-08-27 14:58 UTC (History)
7 users (show)

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments
Sample View (19.58 KB, image/jpeg)
2008-06-26 08:27 UTC, vigor
Details
sample nbproject (11.11 KB, application/x-compressed)
2008-06-26 08:28 UTC, vigor
Details
Wink screencast of a problem (4.19 MB, application/x-compressed)
2008-06-27 15:45 UTC, vigor
Details
Smaller presentation(1.4Mb) (1.34 MB, application/x-compressed)
2008-06-27 16:04 UTC, vigor
Details

Note You need to log in before you can comment on or make changes to this bug.
Description vigor 2008-06-26 08:25:03 UTC
1.
I create a web project in NB 5.5.1 and in web.xml set
<jsp-property-group>
      <display-name>All jsp files</display-name>
      <url-pattern>*.jsp</url-pattern>
      <url-pattern>*.jspa</url-pattern>
      <page-encoding>UTF-8</page-encoding>
    </jsp-property-group> 

Then i create a JSP Page and <b> remove <%@page pageEncoding="UTF-8"%> directive.</b>
 In a page a write some NON ASCII symbols


2.I import this project into SVN

3. I open a project in nb 6.1 and see an SVN diff message on every line in JSP page which is not ASCII. 

PS. I have a Napple thread tor this problem:
http://www.nabble.com/NB-6.1-Error-in-JSP-Editor%28svn-diff-view%29-to18127460.html
Comment 1 vigor 2008-06-26 08:27:14 UTC
Created attachment 63481 [details]
Sample View
Comment 2 vigor 2008-06-26 08:28:23 UTC
Created attachment 63482 [details]
sample nbproject
Comment 3 Marek Fukala 2008-06-26 16:44:37 UTC
Vigor, when you save the JSP page after removing the pageEncoding directive, is the file correct? (if you close/reopen
it, are the non-ascii characters properly shown? And if you look at the diff after reopening is it still showing the bad
characters? 

QE, can some of you you check the behavior on 6.5 builds?
Comment 4 vigor 2008-06-27 06:50:55 UTC
After close and open All pages shows OK, the "diff veiw" give an error 


It's All about <%@page pageEncoding="UTF-8"%>. If I use it on page the "diff view" is OK

If I create a new project with JSPs in NB6.1, import into SNV, then REMOVE  <%@page pageEncoding="UTF-8"%>, I have got
an ERROR!!!

P.S. NB6 shows me an error when I REMOVE directive and then write russian letters. BUT when i Insert

<jsp-config>
        <jsp-property-group>
            <display-name>All jsp files</display-name>
            <url-pattern>*.jsp</url-pattern>
            <url-pattern>*.jspa</url-pattern>
            <page-encoding>UTF-8</page-encoding>
        </jsp-property-group>
    </jsp-config>

The message has gone. 
Comment 5 Marek Fukala 2008-06-27 08:23:37 UTC
>If I create a new project with JSPs in NB6.1, import into SNV, then REMOVE  <%@page pageEncoding="UTF-8"%>, I have got
>an ERROR!!!

That is likely because of the mechanism used for determining the encoding. It first look into the file, if it contains
the pageEncoding directive and if not then asks  parsers. The parser then uses the web.xml to determine the encoding. 

The problem seems to be that by default your encoding is not UTF-8 so if you open the file (loaded as UTF-8 because of
the directive presence) then remove it and then use SVN, it asks for the encoding again and some non UTF-8 encoding is
returned. Adding the encoding to the web.xml fixes the problem since the jsp parser then returns UTF-8 encoding for the
page even there is no pageEncoding directive.

Honestly, I am not sure if this is a bug and if so where. Removing the pageEncoding directive is a step done by user and
in fact it means that you change the semantic of the content of the document. If you then save the page a dialog warning
you about unmappable characters should be shown. If you save anyway some of the non-ascii characters may be lost. The
diff just follows this.
Comment 6 vigor 2008-06-27 12:43:26 UTC
I want to set a pageEncoding 1 time in web.xml.

You are right! i see "save the page a dialog warning" when try to save apage with russian letter UNTIL i set
<jsp-property-group>.
After htat this message do not show and all seems to be good.


Another example.
i want do set pageEncoding 1 time in header.jsp

header.jsp:

<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
   "http://www.w3.org/TR/html4/loose.dtd">

index.jsp

<%@ include file="header.jsp" %>
<html>
    <head>
        
        <title>JSP Page вьссьстьвт   с</title>
    </head>
    <body>
        <h2>Hello World!</h2>
    </body>
</html>

Formally i set page encoding but DIFF VIEW shows an error.

I have 1 big project in NB5.5 (200 jsp) with header and footer. I want to use NB 6.1 and every page looks terrible(full
of diff messages)





p.s. In my observation "diff view " use ISO-8859-1 by default.

 



Comment 7 Marek Fukala 2008-06-27 13:19:15 UTC
Let me summarize a bit ...

1) you CAN set the page encoding one in the deployment descriptor, then all the pages not containing pageEncoding or
contentType (may also specify encoding) will use the value from DD.

2) if you changed the page encoding during its livecycle the diff view is broken - I am not sure how to fix this, adding
diff guys to cc, they probably already solved this.

3) the problem with included pages should be IMHO covered by the parser - if I ask parser for encoding a page A which
statically include page B and B defines encoding while A doesn't the B encoding will be used for A. At least I used to
think it work this way. If not, I am affraid I cannot do much to fix this. Then you need to use the #1 workaround.

So can you somehow easily workaround *all the encoding problems* or should I consider this as a stopper for you? 
Comment 8 Marek Fukala 2008-06-27 14:06:15 UTC
Adding SVN and diff module owners to cc. Can you guys please express your opinion? Thanks.
Comment 9 vigor 2008-06-27 14:08:31 UTC
Let I say it in my words:
 I will creat a project with JSPs then set project encoding property to the UTF-8
 Then set encoding in web.xml(same value UTF-8)for all jsp page.
 Then NB read this setting(web.xml property) and allows me to write JSP content with NON ASCII symbols.
 
 Then i will create as many jsp's as i want without using "page encoding directive"

 Then I import this project into subversion.

I want that "diff window" to work in the same way as "JSP editor" in the meaning of encoding.(JSP editor do not show
russian letter as glyphs and do not show any warning when  saving a page with russian letter).

2)I will not change the page encoding during its livecycle. 
3)Yes, I cannot use NB6.1 for my old projects because i must "enchance" all jsp page with "page encoding directive".

I hope it will help to understand the problem.

 

Comment 10 Marek Fukala 2008-06-27 15:06:33 UTC
Ahh, I see. I thought the problem happens only if you change the encoding in editor (delete the pageEncoding attribute).
So if it work this way it looks like a bug in the SVN or diff.

Jindro or Martin, can you please try to reproduce the problem?
Comment 11 vigor 2008-06-27 15:45:38 UTC
Created attachment 63605 [details]
Wink screencast of a problem
Comment 12 vigor 2008-06-27 16:04:00 UTC
Created attachment 63606 [details]
Smaller presentation(1.4Mb)
Comment 13 Tomas Stupka 2008-06-27 16:10:40 UTC
the editor inline diff encoding is given by the fileencodingquery. Not sure what could be wrong at that place. Will try to reproduce ...
Comment 14 Martin Schovanek 2008-06-27 16:13:48 UTC
preparation:
------------
If you don have a SVN repository then create it like:
$ svnadmin create /tmp/svnrepo

to reproduce:
-------------
1) create a new WebProject
2) open web.xml and insert before root end-tag:
    <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-8</page-encoding>
        </jsp-property-group>
    </jsp-config>
2) type into index.jsp a NON ASCII text and remove <%@page pageEncoding="UTF-8"%> directive
3) right-click project node and choose Versioning > Import into Subversion Repostitory
4) fill the Repository URL eg: file:///tmp/svnrepo
5) finish import wizard
ERROR: diff marks NON ASCII text as modifed and Original Text view is broken.
 
Comment 15 Martin Schovanek 2008-06-27 16:36:43 UTC
P2
Comment 16 Tomas Stupka 2008-07-01 10:43:28 UTC
the fileencodingquery keeps returning utf-8 ...
Comment 17 petkodilchev 2008-07-25 02:40:33 UTC
Hello. I have the same problem, but the problem is not only with Subversion. I have the same problem with SVN, but 
with local history too. I think "p.s. In my observation "diff view" use ISO-8859-1 by default." describes the problem 
best.
In my case i use NB 6.1(same with 6.0) and just create new Web project with Visual Web. The encoding doesn't matter. 
Editing Page1.jsp like that (just adding static text with cyrilic text):

<?xml version="1.0" encoding="UTF-8"?>
<!-- 
    Document   : Page1
    Created on : 2008-7-25, 3:56:40
    Author     : PetkoDilchev
-->
<jsp:root version="2.1" xmlns:f="http://java.sun.com/jsf/core" xmlns:h="http://java.sun.com/jsf/html" 
xmlns:jsp="http://java.sun.com/JSP/Page" xmlns:webuijsf="http://www.sun.com/webui/webuijsf">
    <jsp:directive.page contentType="text/html;charset=UTF-8" pageEncoding="UTF-8"/>
    <f:view>
        <webuijsf:page id="page1">
            <webuijsf:html id="html1">
                <webuijsf:head id="head1">
                    <webuijsf:link id="link1" url="/resources/stylesheet.css"/>
                </webuijsf:head>
                <webuijsf:body id="body1" style="-rave-layout: grid">
                    <webuijsf:form id="form1">
                        <webuijsf:staticText id="staticText1" style="position: absolute; left: 120px; top: 96px" 
text="ПОЗДРАВИ ОТ НОЩНА СОФИЯ"/>
                    </webuijsf:form>
                </webuijsf:body>
            </webuijsf:html>
        </webuijsf:page>
    </f:view>
</jsp:root>


I changed again the text and comparing with local history.
The text shown in left part of diff is "ÐÐÐÐРÐÐÐ ÐТ ÐÐЩÐРСÐФÐÐ"
When i switch all to windows-1251(both file and the entire project) the problem is the same but the text in diff 
is "ÏÎÇÄÐÀÂÈ ÎÒ ÍÎÙÍÀ ÑÎÔÈß"
Comment 18 Marek Fukala 2008-07-30 14:02:51 UTC
It looks like the versioning FEQ provider for temprorary diff files is handled by the JSP FEQ implementation so if the
jsp file is outside of a webmodule and doesn't declare the encoding in the page directive the returned encoding is
ISO-8859-1 and then the diff view is broken.

Reassigning to versioning
Comment 19 Tomas Stupka 2008-07-30 14:27:36 UTC
the inline diffs FEQ implementation returns the encoding given by the FEQ for the file opened in the editor. 

The problem is caused by the fact that the JSP FEQ implementation also claims the temp file for itself and there is no
priority set between the diff and jsp FEQ impls what results in jsp FEQ taking over and returning iso-8859-1.

will set the priority for DiffFileEncodingQueryImpl to 1 as the relevant files are created and meant only for vcs
internal use ...  

fixed fc745d9cc1dc
Comment 20 Quality Engineering 2008-07-31 15:51:57 UTC
Integrated into 'main-golden', available in build *200807311401* on http://bits.netbeans.org/dev/nightly/
Changeset: http://hg.netbeans.org/main/rev/fc745d9cc1dc
User: Tomas Stupka <tstupka@netbeans.org>
Log: #138312 - I18N - Error in JSP Editor(svn diff view)
Comment 21 Ken Frank 2008-08-15 19:35:12 UTC
vigor,

does it look ok for you now in latest netbeans ?


ken.frank@sun.com
Comment 22 vigor 2008-08-19 06:43:27 UTC
I downloaded
netbeans-trunk-nightly-200808170243-javase-windows.exe

and tested it.

The ploblem was solved.

Thanks.
Comment 23 Martin Schovanek 2008-08-27 14:58:54 UTC
v.