我一直在Java上得到这个错误
org.apache.jasper.JasperException:java.lang.NullPointerException
我想要做的是在netbeans 8.1上运行JSP页面。基本上尝试获取sqrt的上限和下限函数域并将其显示在表上。但是当我运行该程序时,我不断在页面上收到该错误。我花了几个小时试图解决它,但我卡住了。任何帮助都会很好。
<%--
Document : Lab 4 - Test cases
Created on : Jan 30, 2016, 6:28:25 PM
Author : David Adade
--%>
<%@page import="lu.engi3255.dadade.lab4.Numerical"%>
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<%@ page import = "java.util.Map" %>
<%@page import="java.util.*" %>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
<title>Math Page</title>
</head>
<body>
<h1>Math Page 1</h1>
<%
String x0, x1, n;
double x, inc;
x0 = request.getParameter("x0");
x1 = request.getParameter("x1");
n = request.getParameter("n");
double lowerbound = Double.parseDouble(x0);
double upperbound = Double.parseDouble(x1);
double domain;
int num = Integer.parseInt(n);
if (x0 == null) {%>
<p>x0 has to be a number</P>
<%
} else {
try {
lowerbound = Double.parseDouble(x0);
} catch (NumberFormatException e) {
n = null;
%>
<p>x0 has to be a number1</p>
<% }
}
if (x1 == null) {
%>
<P>x1 is invalid</p>
<% } else {
try {
upperbound = Double.parseDouble(x1);
} catch (NumberFormatException e) {
x1 = null;
%>
<p>x1 has to be a number </p>
<% }
}
if (n == null) {
%>
<p>n is invalid</p>
<% } else {
try {
num = Integer.parseInt(n);
} catch (NumberFormatException e) {
n = null;
}
}
%>
<p>n has to be a number</p>
<%
if (lowerbound < 0) {
%>
<p>lowerbound has to be greater than 0</p>
<% }
if (lowerbound == upperbound) {
}%>
<p> Lowerbound not equal </p>
<% if ( n != null && x0 != null && x1 != null){
num = Integer.parseInt(n);
lowerbound = Double.parseDouble(x0);
upperbound = Double.parseDouble(x1);
// inc /= num - 1;
%>
<p> invalidentry</p>
<% if (num > 0 && upperbound <= 1) { %>
<table>
<thead>
<tr>
<th>x</th>
<th> y = sqrt(x) +100</th>
</tr>
</thead>
<tbody>
<% for (int i = 0; i < num; i++) {
%>
<tr>
<td><% out.println(String.format("%.3f", lowerbound)); %></td>
<td><% out.println(String.format("%.3f", (Math.sqrt(upperbound)))); %></td>
<% lowerbound = Math.sqrt(lowerbound) + (100);
}
}
}%>
</tr>
</tbody>
</table>
</body>
</html>
这是我第一次使用netbeans,而且我是二年级学生,所以可能会有很多错误。