-1

Main Program

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");
    }
  }
}

Complier Error

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

This is the main code and when I compile using the complier it gives me error. I couldn`t understand that why does it show this error?

1
  • This question is shit: Since you cannot read the clear compiler output, you will not be able to understand the answers in plain english as well. Furthermore, it is too narrow and answering it will not enrich anybody. It is just garbage in the Internet. Finally, it is a duplicate of your the closed question, stackoverflow.com/questions/14252083/…
    – Val
    Jan 11, 2013 at 6:29

2 Answers 2

0

You didn't declare those two variables, right?

In the line:

 dbi.updateDeduction(empId,dedId, dedName, type,dedDate);

both dedId and dedName

So you need to uncomment them... look carefully, just above. I'm guessing there may be another issue though. In general, if it says it can't find XYZ it means it wasn't even declared

2
  • do I need to put them in string?
    – XAH
    Jan 11, 2013 at 5:27
  • Look above the line dbi.updateDeduction(empId,dedId, dedName, type,dedDate); - need to remove comments Jan 11, 2013 at 5:28
0

dedId is not declared and i could find the below line in comments, if you could uncomment your code or below line it might compile.

  //String dedId = bean.getdedId();
  //String dedname = bean.getdedName();

replace this one

//String dedId = bean.getdedId();
//String dedname = bean.getdedName();

with this one

 String dedId = bean.getdedId();
 String dedname = bean.getdedName();
2
  • no its says this error: [javac] /home/student/mcintron/cps4931/maricarmen/src/deduction.java:68: cannot find symbol [javac] symbol : method getdedId() [javac] location: class esss.Shared [javac] String dedId = bean.getdedId();
    – XAH
    Jan 11, 2013 at 5:34
  • @Zain did you write getdedName(); and getdedId(); methods in your Shared object
    – Murali N
    Jan 11, 2013 at 5:56

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.