Javascript org.apache.jasper.jaspereException:java.lang.NullPointerException重复发生
我一直存在这样的问题,每当我尝试运行我的程序时,它都会出现以下错误:Javascript org.apache.jasper.jaspereException:java.lang.NullPointerException重复发生,javascript,netbeans,Javascript,Netbeans,我一直存在这样的问题,每当我尝试运行我的程序时,它都会出现以下错误: HTTP Status 500 - type Exception report message descriptionThe server encountered an internal error () that prevented it from fulfilling this request. exception org.apache.jasper.JasperException: java.lang.Null
HTTP Status 500 -
type Exception report
message
descriptionThe server encountered an internal error () that prevented it from fulfilling this request.
exception
org.apache.jasper.JasperException: java.lang.NullPointerException
root cause
java.lang.NullPointerException
note The full stack traces of the exception and its root causes are available in the GlassFish Server Open Source Edition 3.1.2.2 logs.
GlassFish Server Open Source Edition 3.1.2.2
这是我目前拥有的代码:
<%@page contentType="text/html" pageEncoding="UTF-8" import="java.text.NumberFormat"%>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>JSP Page</title>
</head>
<body>
<%
String strValue, strLife;
strValue=request.getParameter("pValue");
strLife=request.getParameter("pLife");
double value, life, depreciation,totalDepreciation=0;
value=Double.parseDouble(strValue);
life=Double.parseDouble(strLife);
NumberFormat nf = NumberFormat.getCurrencyInstance();
depreciation=value/life;
totalDepreciation=depreciation;
%>
<p>Straight Line Depreciation Table</p>
<p>Property Value: <input type='text' name='pValue' value='<%=nf.format(value)%>' /></p>
<p>Property Life: <input type='text' name='pLife' value='<%=life%>'/></p>
<table border='1' width='400' cellspacing=1>
<thead>
<tr> <th>Year</th> <th>Value at BeginYr</th>
<th>Dep During Yr</th> <th>Total to EndOfYr</th>
</tr>
</thead>
<tbody>
<%
for (int count = 1; count <= life; count++)
{
%>
<tr>
<td width='25%'><%=count%></td>
<td width='25%'><%=nf.format(value)%></td>
<td width='25%'><%=nf.format(depreciation)%></td>
<td width='25%'><%=nf.format(totalDepreciation)%></td>
</tr>
<%
value -= depreciation;
totalDepreciation+=depreciation;
}
%>
</table>
JSP页面
直线折旧表
属性值:
物业寿命:
年初价值
年内截至财年的总折旧率
如果“pValue”和“pLifet”不在查询字符串中,那么可能会使查询字符串的分析变得混乱?我以为那是网址。如何确保它们位于查询字符串中?是的,查询字符串是URL中超过?
的所有内容。例如,如果您有URL:http://www.example.com/some/page.jsp?pValue=something&pLife=somethingElse
,查询字符串是pValue=something&pLife=somethingElse
。因此,我的观点是,您必须使用一个查询字符串请求页面,该字符串为pValue
和pLife
提供值。如果您没有提供它们,那么您的代码行中的value=Double.parseDouble(strValue)代码>将失败,因为strValue
将为空或null。只要您总是使用这两个值请求URL,那么问题就在于,我在哪里可以查看文件的URL?我甚至找不到查询字符串来检查它是否提供了这些值。