title: Math.sqrt(-5) -> Force Exception in JSP?
body: <p>I've 3 .jsp files. index.jsp and sqrtcalculator.jsp and error.jsp.</p>
  
  <p>In index.jsp there's a text field and a button. In sqrtcalculator.jps there's the, well, calculator.</p>
  
  <p>Now, when I leave the field empty and press the button, an expection is called, because the field is empty. And I can then reroute to an individual error.jsp site to display the errors, and exception stack like</p>
  
  <pre><code>&lt;%= request.getAttribute("javax.servlet.error.request_uri") %&gt;
  &lt;%= exception.getMessage() %&gt;
  &lt;%= exception %&gt;
  </code></pre>
  
  <p>etc.</p>
  
  <p>Problem is, when I enter -5 in the textfield, I can't get an exception, because Math.sqrt(-5) doesn't return an error but "NaN".</p>
  
  <p>How can I force it to be an exception? The idea is to reroute the user to an individual error.jsp and displaying the errors. But like I said Math.sqrt(-5) doesn't return errors or exceptions but "NaN" textstring.</p>
  
  <p>I don't want something like this just FYI</p>
  
  <pre><code>&lt;%if (NaN){
  %&gt;
  &lt;p&gt;Nope, Square root from negative numbers is not defined!&lt;/p&gt;
  &lt;%}
  %&gt;
  </code></pre>