Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>First of all, it's not recommended to embed java code in a java servlet page, you should only take care of the presentation layer in the jsp, no business logic, you need a servlet to take the http request, do your logic, put the results on the response, and then redirect to the jsp.</p> <p>On the other hand the exception type thrown by the JSP page is org.apache.jasper.JasperException, and not NumberFormatException, the apache jasper JSP engine is catching the number format exception, and throwing a JasperException to Tomcat. </p> <p>Also, clear your tomcat cache to ensure that your JSP is being deployed to the last version, in order to do so, delete the following folders and files (including war):<br> {tomcat installation path}\work\Catalina\localhost(your app)<br> {tomcat installation path}\webapps(your app)</p> <p>It should work if you catch the generic java.lang.Exception.</p> <p>Also try this:</p> <hr> <pre><code> final double MA_TO_A = 0.001; int Svolt = 0; double Amperes = 0.0; double LEDdrop = 0.0; try { if (request.getParameter("Svolt") != null) { try { Svolt = Integer.parseInt(request.getParameter("Svolt")); } catch (Exception e) { //Changed to avoid the message if no exception, or for some other reason it fails to execute the conditions out.println("&lt;script type =\"text/javascript\"&gt;") out.println("alert(\"The source voltage must be an integer. Please fix this.\");") ; out.println("&lt;/script&gt;") } Amperes = Double.parseDouble(request.getParameter("Amperes")); LEDdrop = Double.parseDouble(request.getParameter("LEDdrop")); out.println("Ideal resistance is: " + ((Svolt - LEDdrop) / (Amperes * MA_TO_A)) + " Ohms."); } } catch (Exception e) { out.println("Please make sure your inputs are correct."); } </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload