Reviewing some legacy source files, I came across a jsp with the following code:
<%@page pageEncoding="UTF-8"
language="java"
contentType="text/html" %>
<%-- omitted... --%>
<c:set var="abtNummer" value="0"/>
<%-- omitted... --%>
<c:set var="abtNummer" value="${abtNummer + 1}"/>
<a href="#abt${abtNummer}"> ${section}</a>
<%-- omitted... --%>
NetBeans is reporting the following parsing error for the <a href...> element:
Bad value "#abt " for attribute "href" on element "a": DOUBLE_WHITESPACE in
FRAGMENT.
Syntax of IRI reference:
Any URL. For example: '/hello', '#canvas', or 'http://example.org/'. Characters
should be represented in NFC and spaces should be escaped as '%20'.
I would say that NetBeans is trying to resolve ${abtNummer} during the live-parsing?
Both abtNummer and section have valid runtime values, and in fact, the code works. After a few hours reading JSP and EL specs (I’m not a Java EE expert), and searching for NetBeans bugs, I have convinced myself that the line is completely legal, and that it doesn’t need any kind of improvement.
I was about to file a bug against NetBeans, but I am not sure that this is a bug: is there anything I have to add to this JSP to signal NetBeans not to validate dynamic content for these kind of attributes? Or am I just doing something wrong?
Edit:
I have filed a bug: Wrong html parsing error when editing jsp fragment
Tested with NetBeans 7.1 and 7.1.2.
As I mentioned in the reported bug, you can config this warning in
Tools -> Options -> Editor -> Hints -> HTML Validator -> Attribute: