Unequal sign ("<") in javascript in xthml file for jsf causes an error (in netbeans)

Possible duplicate:
javax.servlet.ServletException: Error analysis /page.xhtml: Element content should consist of well-formed character data or markup

This is a jsf 2.0 project.

Xhtml file:

 <?xml version='1.0' encoding='UTF-8' ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xmlns:h="http://java.sun.com/jsf/html"> <h:head> <title>Ring</title> <h:outputScript library="js" name="jquery-1.8.1.min.js" /> <h:outputScript library="js" name="processing-1.4.1.js" /> <script type="text/javascript"> $(function(){ var pjs = Processing.getInstanceById("viz"); var json = #{TableMatchesBean.json}; var data = eval("("+json+")"); if(data) { for(i=0; i<data.segments.length; i++) { var segment = data.segments[i]; pjs.addSegment(segment.label, segment.count,segment.isMain); } } }); //end ready </script> </h:head> <h:body> <canvas id ="viz" data-processing-sources="common.pde"></canvas> </h:body> </html> 

In the first line of a for loop in javascript

 for(i=0; i<data.segments.length; i++) { 

Netbeans causes this error: "Fatal error: the element type" data.segments.length "must be followed by the specification of the attributes"> "or"] ".

This error assumes that the "<" is interpreted as some xhtml, and not as js (I think). Is this a Netbeans bug or is there really a confusion between js and xhtml here?

+4
source share
1 answer

Move JavaScript code to external JavaScript file

or

Use CDATA

 <script type="text/javascript"> //<![CDATA[ var i = 0; while (++i < 10) { // ... } //]]> </script> 
+17
source

Source: https://habr.com/ru/post/1432815/


All Articles