Please use the Apache issue tracking system for new NetBeans issues (https://issues.apache.org/jira/projects/NETBEANS0/issues) !!
Bug 192803 - Incorrect JSP file formating
Incorrect JSP file formating
Status: RESOLVED FIXED
Product: javaee
Classification: Unclassified
Component: JSP
7.0
Macintosh (x86) Linux
: P3 (vote)
: TBD
Assigned To: Anton Chechel
issues@javaee
:
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2010-12-02 14:43 UTC by pragalathan
Modified: 2010-12-10 06:15 UTC (History)
5 users (show)

See Also:
Issue Type: DEFECT
:


Attachments
Sample JSP file formatted incorectly (36.98 KB, image/png)
2010-12-02 14:43 UTC, pragalathan
Details
Formatted JSP (31.65 KB, image/png)
2010-12-09 11:25 UTC, pragalathan
Details

Note You need to log in before you can comment on or make changes to this bug.
Description pragalathan 2010-12-02 14:43:41 UTC
Created attachment 103538 [details]
Sample JSP file formatted incorectly

JSP file formatter does not format the content correctly if the JSP (custom) tag contains any attribute starting with '_'.
This is my observation. Cause may be different. Attached the screen shot of a JSP file after formating
Comment 1 pragalathan 2010-12-03 06:33:07 UTC
The formatter underlines '_' as error for any attribute starting with underscore.
Comment 2 David Konecny 2010-12-07 23:00:26 UTC
Marek, can custom tag's attribute name starts with underscore character??
Comment 3 Marek Fukala 2010-12-08 13:48:08 UTC
If I am reading the JSP 2.2 spec correctly it says the custom tag's attribute name should be a XML name (XML::Name). The non-normative part of XML spec says XML name can start with underscore.

The problem here is that the JSP custom tags are not recognized properly (would be in bold font if so) hence considered as html code by the editor. And AFAIK html tags' attribute names cannot start with underscore so the html lexer considers then as errors.

I do not have an idea how such situation is handled by the formatting infrastructure. I can just guess it considers the unknown html tags as xml tags and formats accordingly. I also assume the formatter scans the document at lexical level for tags so the broken html tags lexing affects the process significantly.

I can fix the html lexer so the attributes started with underscore are not considered as lexical error if that will help. Such tags will be flagged as errors by the validator anyway.
Comment 4 David Konecny 2010-12-08 18:44:57 UTC
Thanks Marek. I think that pragalathan when he talks about "formatting" he refers to attributes starting with underscore not being bold and being marked as erroneous. So what needs to be fixed first is "the JSP custom tags are not recognized properly". I'm leaving that one for Anton.
Comment 5 pragalathan 2010-12-09 05:40:14 UTC
Thanks Marek and David for the detailed explanation.

There are two issues. 

1. As David said, the attributes starting with _ are not recognized as attributes and shown as errors(with red underline).

2. when you use Alt+Shift+F to format the code, the indentation is not correct as you can see in the screen shot attached. eg. yt_apex:row, yt_apex:module and span tags, etc

As per the explanation above, what I understand is that making the lexer recognize
attribute may fix the indentation too, as Marek said.
Comment 6 David Konecny 2010-12-09 06:49:55 UTC
(In reply to comment #5)
> 2. when you use Alt+Shift+F to format the code, the indentation is not correct
> as you can see in the screen shot attached. eg. yt_apex:row, yt_apex:module and
> span tags, etc

Sorry, I did not really notice the indentation problem, although on second look at your screenshot it is pretty obvious. :-) Yeap, it is very likely side effect of attributes not being recognized.
Comment 7 Marek Fukala 2010-12-09 10:08:30 UTC
The problem with underscore as the first character of attribute name fixed in web-main#556b45749edf

I'm not closing the issue, please verify it the formatting works properly David. Thanks.
Comment 8 Marek Fukala 2010-12-09 10:10:57 UTC
And of course Anton should verify why the tags are not recognized as JSP custom tags. I believe there's not enough information for this pragalathan. Can you please doublecheck if your project is properly configured? A sufficient way should be to deploy and check if works. If so there's a bug in netbeans. In such case, could you please pack the project or its part which can be used to demonstrate the issue? Thanks in advance.
Comment 9 pragalathan 2010-12-09 11:25:30 UTC
Created attachment 103822 [details]
Formatted JSP

Sorry folks for not utilizing your times effectively.

I tried resolving all the POM dependencies. And now I'm able to format(indention) properly. 

However I remember once I said the IDE not to check errors on this JSP file when I saw too many error underline.

But they are no more. And the attribute with _ is in green color (I assume that lexer recognized it properly)
Comment 10 Marek Fukala 2010-12-09 12:15:59 UTC
No problem. The original usecase is still valid since one may want to work with the code even if the libraries are unresolved. Since there doesn't seem to be a problem on the JSP parser side and the lexing of underline prefixed html attributes has been fixed today I consider this issue as fixed.

Thanks for your feedback.
Comment 11 Quality Engineering 2010-12-10 06:15:03 UTC
Integrated into 'main-golden', will be available in build *201012100001* on http://bits.netbeans.org/dev/nightly/ (upload may still be in progress)
Changeset: http://hg.netbeans.org/main/rev/556b45749edf
User: Marek Fukala <mfukala@netbeans.org>
Log: #192803 - Incorrect JSP file formating


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