title: alert() not working in JSP
body: <p>I am calling a Javascript <code>test()</code> function for validation purpose before it can be committed. This function has Java scriptlets where validation logic is return and it updated a boolean variable. Using this boolean variable, I am checking if this js function should return true or false. If false then it is negative case of validation and in true positive case of validation.</p>
  
  <p>The general code is something like:</p>
  
  <pre><code>&lt;% boolean check = false ; %&gt;
  &lt;script&gt;
  function test(){
  /*
  * java code for updating test variable for validating values on the jsp page
  */
  
  if(!check){
  &lt;% System.out.println("this runs ! "); %&gt; // line 1
  alert("validation fails"); // line 2
  return false;
  }
  else return true;
  
  }
  &lt;/script&gt;
  ..
  ..
  &lt;input type="submit".. onclick="return test()"&gt;
  ..
  ..
  </code></pre>
  
  <p>Is it going wrong somewhere? I have been trying a lot of things for line 1 to run, but it doesnt. My code execution reached inside the if check at line 1, but doesnt alert i.e line 2 and the validation thing also doesnt work.</p>
  
  <p>Someone had similar issues? What is the resolution?</p>