主程序
package esss;
// Add
import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;
import esss.DBI;
import esss.Shared;
import esss.Control;
public class deduction extends esss.Control {
protected DBI dbi;
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException
{
HttpSession session = request.getSession();
esss.Shared bean = (esss.Shared)session.getAttribute("shared");
//String[] checked = request.getParameter("deduction");// needs parameter
String type = request.getParameter("deduction");// needs parameter
String amount = request.getParameter("amount");
addDeduction(bean, type, amount);
gotoPage("/mainPage.jsp", request, response);
}
public void addDeduction(esss.Shared bean,String type, String amount) throws ServletException{
try {
dbi = new esss.DBI();
if(dbi.connect()) {
String payment ="";
if(type.equals("Parking Lot A")) {
payment="10";
}
else if(type.equals("Parking Lot B")) {
payment="5";
}
else if(type.equals("Extra Life Insurance(Age<35, 50,000)")) {
payment="5";
}
else if(type.equals("Extra Life Insurance(Age 35-55, 25,000)")) {
payment="17";
}
else if(type.equals("Extra Life Insurance(Age>55, 10,000)")) {
payment="35";
}
if(!(type.equals("none"))) {
String empId= bean.getEmpId();
String dedDate = bean.getCurrentDate();
//String dedId = bean.getdedId();
//String dedname = bean.getdedName();
//String dedAmount = bean.getAmount();
dbi.updateDeduction(empId,dedId, dedName, type,dedDate);
bean.setMessage("Deduction Added");
}
else {
bean.setMessage("Please make sure you perfrom deduction");
}
dbi.close();
}
}catch(Exception e) {
e.printStackTrace();
bean.setMessage("Exception caught : " + e);
bean.setError("The database could not be connected");
}
}
}
编译器错误
compile:
[javac] Compiling 22 source files to /home/student/mcintron/cps4931/maricarmen/build/WEB-INF/classes
[javac] /home/student/mcintron/cps4931/maricarmen/src/deduction.java:71: cannot find symbol
[javac] symbol : variable dedId
[javac] location: class esss.deduction
[javac] dbi.updateDeduction(empId,dedId, dedName, type,dedDate);
[javac] ^
[javac] /home/student/mcintron/cps4931/maricarmen/src/deduction.java:71: cannot find symbol
[javac] symbol : variable dedName
[javac] location: class esss.deduction
[javac] dbi.updateDeduction(empId,dedId, dedName, type,dedDate);
[javac] ^
[javac] 2 errors
BUILD FAILED
这是主要代码,当我使用编译器进行编译时,它给了我错误。我不明白为什么它会显示这个错误?