title: org.mozilla.javascript.EvaluatorException: illegal character when i using HtmlUnit
body: <p>I am using the <a href="http://httpunit.sourceforge.net" rel="nofollow">HttpUnit</a> to simulate the submit button click of the form that designed into the specified url. (I am using <code>http://stu21.kntu.ac.ir/Login.aspx</code>). I use the code as follow to get response page.</p>
  
  <pre><code>    WebConversation conversation = new WebConversation();
      WebRequest request = new GetMethodWebRequest("http://stu21.kntu.ac.ir/Login.aspx");
      WebResponse response = conversation.getResource(request);       
  
      WebForm loginForm = response.getForms()[0]; //Form has been got successfully
      request = loginForm.getRequest();
      request.setParameter("txtusername", "8810103" );
      request.setParameter("txtpassword", "8810103" );
      response = conversation.getResponse( request ); //error while getting the .js files
  </code></pre>
  
  <p>It gets the form successfully, but when i fill out the form and want to submit my form, the error occurred as follow :</p>
  
  <blockquote>
    <p>org.mozilla.javascript.EvaluatorException: illegal character  at
    org.mozilla.javascript.DefaultErrorReporter.runtimeError(DefaultErrorReporter.java:98)
      at
    org.mozilla.javascript.DefaultErrorReporter.error(DefaultErrorReporter.java:85)
      at org.mozilla.javascript.Parser.addError(Parser.java:126)  at
    org.mozilla.javascript.TokenStream.getToken(TokenStream.java:810)     at
    org.mozilla.javascript.Parser.peekToken(Parser.java:144)  at
    org.mozilla.javascript.Parser.primaryExpr(Parser.java:1953)   at
    org.mozilla.javascript.Parser.memberExpr(Parser.java:1641)    at
    org.mozilla.javascript.Parser.unaryExpr(Parser.java:1507)     at
    org.mozilla.javascript.Parser.mulExpr(Parser.java:1436)   at
    org.mozilla.javascript.Parser.addExpr(Parser.java:1417)   at
    org.mozilla.javascript.Parser.shiftExpr(Parser.java:1397)     at
    org.mozilla.javascript.Parser.relExpr(Parser.java:1371)   at
    org.mozilla.javascript.Parser.eqExpr(Parser.java:1327)    at
    org.mozilla.javascript.Parser.bitAndExpr(Parser.java:1316)    at
    org.mozilla.javascript.Parser.bitXorExpr(Parser.java:1305)    at
    org.mozilla.javascript.Parser.bitOrExpr(Parser.java:1294)     at
    org.mozilla.javascript.Parser.andExpr(Parser.java:1282)   at
    org.mozilla.javascript.Parser.orExpr(Parser.java:1270)    at
    org.mozilla.javascript.Parser.condExpr(Parser.java:1253)  at
    org.mozilla.javascript.Parser.assignExpr(Parser.java:1235)    at
    org.mozilla.javascript.Parser.expr(Parser.java:1224)  at
    org.mozilla.javascript.Parser.statementHelper(Parser.java:1111)   at
    org.mozilla.javascript.Parser.statement(Parser.java:623)  at
    org.mozilla.javascript.Parser.parse(Parser.java:355)  at
    org.mozilla.javascript.Parser.parse(Parser.java:293)  at
    org.mozilla.javascript.Context.compileImpl(Context.java:2238)     at
    org.mozilla.javascript.Context.compileString(Context.java:1284)   at
    org.mozilla.javascript.Context.compileString(Context.java:1273)   at
    org.mozilla.javascript.Context.evaluateString(Context.java:1129)  at
    com.meterware.httpunit.javascript.ScriptingEngineImpl.runScript(ScriptingEngineImpl.java:92)
      at
    com.meterware.httpunit.scripting.ScriptableDelegate.runScript(ScriptableDelegate.java:88)
      at
    com.meterware.httpunit.parsing.NekoDOMParser.runScript(NekoDOMParser.java:151)
      at
    com.meterware.httpunit.parsing.ScriptFilter.getTranslatedScript(ScriptFilter.java:150)
      at
    com.meterware.httpunit.parsing.ScriptFilter.endElement(ScriptFilter.java:131)
      at
    org.cyberneko.html.filters.DefaultFilter.endElement(DefaultFilter.java:249)
      at
    org.cyberneko.html.filters.NamespaceBinder.endElement(NamespaceBinder.java:367)
      at
    org.cyberneko.html.HTMLTagBalancer.callEndElement(HTMLTagBalancer.java:1015)
      at
    org.cyberneko.html.HTMLTagBalancer.endElement(HTMLTagBalancer.java:888)
      at
    org.cyberneko.html.HTMLScanner$SpecialScanner.scan(HTMLScanner.java:2831)
      at org.cyberneko.html.HTMLScanner.scanDocument(HTMLScanner.java:809)
      at
    org.cyberneko.html.HTMLConfiguration.parse(HTMLConfiguration.java:478)
      at
    org.cyberneko.html.HTMLConfiguration.parse(HTMLConfiguration.java:431)
      at org.apache.xerces.parsers.XMLParser.parse(Unknown Source)    at
    org.apache.xerces.parsers.DOMParser.parse(Unknown Source)     at
    com.meterware.httpunit.parsing.NekoHTMLParser.parse(NekoHTMLParser.java:48)
      at com.meterware.httpunit.HTMLPage.parse(HTMLPage.java:271)     at
    com.meterware.httpunit.WebResponse.getReceivedPage(WebResponse.java:1301)
      at
    com.meterware.httpunit.WebResponse.getFrames(WebResponse.java:1285)
      at
    com.meterware.httpunit.WebResponse.getFrameRequests(WebResponse.java:1024)
      at
    com.meterware.httpunit.FrameHolder.updateFrames(FrameHolder.java:179)
      at
    com.meterware.httpunit.WebWindow.updateFrameContents(WebWindow.java:315)
      at
    com.meterware.httpunit.WebClient.updateFrameContents(WebClient.java:526)
      at com.meterware.httpunit.WebWindow.updateWindow(WebWindow.java:201)
      at
    com.meterware.httpunit.WebWindow.getSubframeResponse(WebWindow.java:183)
      at com.meterware.httpunit.WebWindow.getResponse(WebWindow.java:158)
      at com.meterware.httpunit.WebWindow.updateWindow(WebWindow.java:199)
      at
    com.meterware.httpunit.WebWindow.getSubframeResponse(WebWindow.java:183)
      at com.meterware.httpunit.WebWindow.getResponse(WebWindow.java:158)
      at com.meterware.httpunit.WebWindow.updateWindow(WebWindow.java:199)
      at
    com.meterware.httpunit.WebWindow.getSubframeResponse(WebWindow.java:183)
      at com.meterware.httpunit.WebWindow.getResponse(WebWindow.java:158)
      at com.meterware.httpunit.WebClient.getResponse(WebClient.java:122)
      at Main.main(Main.java:76) Exception in thread "main"
    com.meterware.httpunit.ScriptException: Script 'ï»¿var shuffleArray =
    new Array(); //var field = ""; shuffle = function (o) { //v1.0</p>
  
  <pre><code>for (var j, x, l = o.length; l; j = parseInt(Math.random() * l), x = o[--l], o[l] = o[j], o[j] = x);
  for (var H = 0; H &lt; 10; H++) {
      shuffleArray[H] = o[H];
  }
  return o; }
  </code></pre>
    
    <p>////////////////////////////////Key Pad Script function KeyPadInit() {
        alert("yes");
        var randomnumber;
        var myNumbers = new Array();</p>
  
  <pre><code>for (jj = 0; jj &lt; 10; jj++) {
      randomnumber = Math.floor(Math.random() * 10);
      while (IsInArray(myNumbers, randomnumber) == 1) {
          randomnumber = Math.floor(Math.random() * 10);
      };
      switch (jj) {
          case 0: document.getElementById('btnSeven0').value = randomnumber; break;
          case 1: document.getElementById('btnSeven1').value = randomnumber; break;
          case 2: document.getElementById('btnSeven2').value = randomnumber; break;
          case 3: document.getElementById('btnSeven3').value = randomnumber; break;
          case 4: document.getElementById('btnSeven4').value = randomnumber; break;
          case 5: document.getElementById('btnSeven5').value = randomnumber; break;
          case 6: document.getElementById('btnSeven6').value = randomnumber; break;
          case 7: document.getElementById('btnSeven7').value = randomnumber; break;
          case 8: document.getElementById('btnSeven8').value = randomnumber; break;
          case 9: document.getElementById('btnSeven9').value = randomnumber; break;
      }
      myNumbers[myNumbers.length] = randomnumber;
  }
  </code></pre>
    
    <p>}</p>
    
    <p>function IsInArray(objArray, num) {
        for (i = 0; i &lt;= objArray.length - 1; i++) {
            if (objArray[i] == num)
                return 1;
        }
        return 0; }</p>
    
    <p>function ChangeStyle(objbtn, action) {</p>
  
  <pre><code>if (action == 'out') {
      objbtn.className = 'PadStyle';
  }
  else if (action == 'over') {
      objbtn.className = 'PadStyleOver';
  }
  </code></pre>
    
    <p>}</p>
    
    <p>var inpId = new Array(); var shuffleArray = new Array();</p>
    
    <p>//<strong><em>*</em>**<em>*</em>**<em>*</em>**<em>*</em>**<em>*</em>**<em>*</em>**<em>*</em>***</strong><em>Comput the number of Input
    box</em><strong><em>*</em>**<em>*</em>**<em>*</em>**<em>*</em>**<em>*</em>**<em>*</em>**<em>*</em>**<em>*</em>**<em>*</em>***</strong> fillArray =
    function () {
        inpId.splice(0, inpId.length - 1);
        var i = 0;
        var InputsId = document.getElementsByTagName("input");
        for (var k = 0; k &lt; InputsId.length; k++) {
            if ((InputsId[k].type == "text") || (InputsId[k].type == "password") || (InputsId[k].type == "checkbox") || (InputsId[k].type
    == "submit")) {
                if (!(InputsId[k].disabled)) {
                    inpId[i++] = InputsId[k];
                }
            }
        } }</p>
    
    <p>function AmountMaskE2(amount) {
        var i, j, mystring, flag;</p>
  
  <pre><code>if (amount == '')
      return "";
  
  i = amount.length;
  
  
  mystring = "";
  for (j = 0; j &lt; i; j++) {
      if (amount.substring(j, j + 1) == ",") {
          flag = true;
      }
  }
  
  if (flag == true) {
      amount = DAmountMaskE(amount);
  }
  i = amount.length;
  if (i &gt; 3) {
      for (j = i; j &gt; 0; j = j - 3) {
  
          if (j &gt; 3) {
              mystring = "," + amount.substring(j - 3, j) + mystring;
  
          } else {
              mystring = amount.substring(0, j) + mystring;
          }
      }
  
      return mystring;
  } else {
  
      return amount;
  }
  </code></pre>
    
    <p>}</p>
    
    <p>function DAmountMaskE(amount) {
        var i, j, mystring, str;
        i = amount.length;
        mystring = "";</p>
  
  <pre><code>for (j = i; j &gt;= 0; j -= 1) {
      str = amount.substring(j, j - 1);
      if (str != ",") {
          mystring = str + mystring;
      }
  }
  return mystring; }' failed: org.mozilla.javascript.EvaluatorException: illegal character  at
  </code></pre>
    
    <p>com.meterware.httpunit.javascript.ScriptingEngineImpl.handleScriptException(ScriptingEngineImpl.java:64)
      at
    com.meterware.httpunit.javascript.ScriptingEngineImpl.runScript(ScriptingEngineImpl.java:95)
      at
    com.meterware.httpunit.scripting.ScriptableDelegate.runScript(ScriptableDelegate.java:88)
      at
    com.meterware.httpunit.parsing.NekoDOMParser.runScript(NekoDOMParser.java:151)
      at
    com.meterware.httpunit.parsing.ScriptFilter.getTranslatedScript(ScriptFilter.java:150)
      at
    com.meterware.httpunit.parsing.ScriptFilter.endElement(ScriptFilter.java:131)
      at
    org.cyberneko.html.filters.DefaultFilter.endElement(DefaultFilter.java:249)
      at
    org.cyberneko.html.filters.NamespaceBinder.endElement(NamespaceBinder.java:367)
      at
    org.cyberneko.html.HTMLTagBalancer.callEndElement(HTMLTagBalancer.java:1015)
      at
    org.cyberneko.html.HTMLTagBalancer.endElement(HTMLTagBalancer.java:888)
      at
    org.cyberneko.html.HTMLScanner$SpecialScanner.scan(HTMLScanner.java:2831)
      at org.cyberneko.html.HTMLScanner.scanDocument(HTMLScanner.java:809)
      at
    org.cyberneko.html.HTMLConfiguration.parse(HTMLConfiguration.java:478)
      at
    org.cyberneko.html.HTMLConfiguration.parse(HTMLConfiguration.java:431)
      at org.apache.xerces.parsers.XMLParser.parse(Unknown Source)    at
    org.apache.xerces.parsers.DOMParser.parse(Unknown Source)     at
    com.meterware.httpunit.parsing.NekoHTMLParser.parse(NekoHTMLParser.java:48)
      at com.meterware.httpunit.HTMLPage.parse(HTMLPage.java:271)     at
    com.meterware.httpunit.WebResponse.getReceivedPage(WebResponse.java:1301)
      at
    com.meterware.httpunit.WebResponse.getFrames(WebResponse.java:1285)
      at
    com.meterware.httpunit.WebResponse.getFrameRequests(WebResponse.java:1024)
      at
    com.meterware.httpunit.FrameHolder.updateFrames(FrameHolder.java:179)
      at
    com.meterware.httpunit.WebWindow.updateFrameContents(WebWindow.java:315)
      at
    com.meterware.httpunit.WebClient.updateFrameContents(WebClient.java:526)
      at com.meterware.httpunit.WebWindow.updateWindow(WebWindow.java:201)
      at
    com.meterware.httpunit.WebWindow.getSubframeResponse(WebWindow.java:183)
      at com.meterware.httpunit.WebWindow.getResponse(WebWindow.java:158)
      at com.meterware.httpunit.WebWindow.updateWindow(WebWindow.java:199)
      at
    com.meterware.httpunit.WebWindow.getSubframeResponse(WebWindow.java:183)
      at com.meterware.httpunit.WebWindow.getResponse(WebWindow.java:158)
      at com.meterware.httpunit.WebWindow.updateWindow(WebWindow.java:199)
      at
    com.meterware.httpunit.WebWindow.getSubframeResponse(WebWindow.java:183)
      at com.meterware.httpunit.WebWindow.getResponse(WebWindow.java:158)
      at com.meterware.httpunit.WebClient.getResponse(WebClient.java:122)
      at Main.main(Main.java:76)</p>
  </blockquote>
  
  <p>Can any one give me a solution to solve my problem ?</p>