0

我一直遇到这个问题,每当我尝试运行我的程序时,都会出现这个错误:

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>

我遇到这个问题的原因是什么?错误报告非常无用,我在网上找不到太多帮助。非常感谢!

4

0 回答 0