1

I have a very easy javascript code inside an xhtml page, but Glassfish doesn't want to render it due an internal error:

 javax.servlet.ServletException: Error Parsing /basicuser/singletripcreation.xhtml: Error Traced[line: 14] Il riferimento di entità "callback" deve terminare con il delimitatore ';'.     

the code involved at the line 14 is the following

 <script language="Javascript">
 function loadGoogleMapsScript()
 {
     var script = document.createElement("script");
     script.type = "text/javascript";  
     script.src = "http://maps.google.com/maps/api/js?sensor=false&callback=visualizzamappa";
     document.body.appendChild(script);
 }
 loadGoogleMapsScript();
 </script>

the 14th line is "script.src = ...."

what is wrong?! the error looks like inside the string. I this is a compilation error, why the compiler check inside a string?!? (yes the error is shown even before the execution, like compilation error)

How could i solve?!

thankyou very much

---- @Mike

Now the error is on :

   for (var x=0; x<indirizzi.length ; x++)
       codifica_indirizzi(indirizzi[x], descrizioni[x]);

and say:

 javax.servlet.ServletException: Error Parsing /basicuser/singletripcreation.xhtml: Error Traced[line: 47] Il tipo di elemento "indirizzi.length" deve essere seguito dalle specifiche di attributo ">" o "/>".

causa principale

"the kind of element 'indirizzi.length' must be followed by the specificaton ot attribute '>' or '/<'"

Sam
  • 313
  • 4
  • 21
  • Il riferimento di entità "callback" deve terminare con il delimitatore ';'. means in english "the reference to the entity callback must terminate with the delimeter ';'." – Sam Jan 05 '15 at 14:13
  • The compiler still show an arror on the line 14 even it i put it like a javascript comment . – Sam Jan 05 '15 at 14:21
  • Can you add an example of what it looked like after you changed it? Does the error message change? – Mike Jan 05 '15 at 14:22

1 Answers1

2

This answer tells you the problem and how to solve it https://stackoverflow.com/a/14112363/212224

it is the ampersand (&) in the URL that is causing problems. it means that the ...&callback... part of the URL is viewed as an XML element. The & symbol should be replaced by & so the full line 14 should read:

script.src = "http://maps.google.com/maps/api/js?sensor=false&amp;callback=visualizzamappa";

If you have any other characters causing similar problems, Wikipedia has a list of XML entity names: http://en.wikipedia.org/wiki/List_of_XML_and_HTML_character_entity_references

Community
  • 1
  • 1
Mike
  • 4,852
  • 1
  • 29
  • 48
  • thankyou really much Mike!!! now that error disappeard, but i have another error on 'for (var x=0; x" or "/>"** .... – Sam Jan 05 '15 at 14:28
  • Hey I solved. Instead write < in the code, just you should use &lt;. It is crazy, but it works. thankyou very much for your help – Sam Jan 05 '15 at 14:49
  • No problem. I updated my answer with a link to a Wikipedia page with a list of all the different characters and their entity names for reference. – Mike Jan 05 '15 at 15:01