html – I'm not getting output from java servlet-ThrowExceptions

Exception or error:

I’m not getting final price output, when I click button page redirects to servlet, gets everything from it, but there is no output of final price. In html page I’m using radio buttons for selection. Any advice is welcome. Thank you.
here is servlet code:

 response.setContentType("text/html;charset=UTF-8");
    double pristupUmnozak =0;
    double lokacijaUmnozak =0;
    double gabaritiUmnozak =0;
    double vrstaUmnozak =0;
    double infraUmnozak =0;
    double terenUmnozak =0;
    double formula;
    double pocetna = 1000;
    double cijena;

    String pristup = String.valueOf(request.getParameter("pristup"));
    String lokacija = String.valueOf(request.getParameter("lokacija"));
    String gabariti = String.valueOf(request.getParameter("gabariti"));
    String vrsta = String.valueOf(request.getParameter("vrsta"));
    String infra = String.valueOf(request.getParameter("infra"));
    String teren = String.valueOf(request.getParameter("teren"));

    if(pristup.equals("odlican")){
        pristupUmnozak = 1.2;
    }
    if(pristup.equals("dobar")){
        pristupUmnozak = 0.9;
    }
    if(pristup.equals("los")){
        pristupUmnozak = 0.6;
    }
    if(lokacija.equals("odlican")){
        lokacijaUmnozak = 1.2;
    }
    if(lokacija.equals("dobar")){
        lokacijaUmnozak = 0.9;
    }
    if(lokacija.equals("los")){
        lokacijaUmnozak = 0.6;
    }
    if(gabariti.equals("odlican")){
        gabaritiUmnozak = 1.2;
    }
    if(gabariti.equals("dobar")){
        gabaritiUmnozak = 0.9;
    }
    if(gabariti.equals("los")){
        gabaritiUmnozak = 0.6;
    }
    if(vrsta.equals("odlican")){
        vrstaUmnozak = 1.2;
    }
    if(vrsta.equals("dobar")){
        vrstaUmnozak = 0.9;
    }
    if(vrsta.equals("los")){
        vrstaUmnozak = 0.6;
    }
    if(infra.equals("odlican")){
        infraUmnozak = 1.2;
    }
    if(infra.equals("dobar")){
        infraUmnozak = 0.9;
    }
    if(infra.equals("los")){
        infraUmnozak = 0.6;
    }
    if(teren.equals("odlican")){
        terenUmnozak = 1.2;
    }
     if(teren.equals("dobar")){
        terenUmnozak = 0.9;
    }
      if(teren.equals("los")){
        terenUmnozak = 0.6;
    }

    formula = Services2.konacnaCijena(pristupUmnozak, lokacijaUmnozak, gabaritiUmnozak, vrstaUmnozak, 
    infraUmnozak, terenUmnozak);
     cijena = pocetna*formula;
     try (PrintWriter out = response.getWriter()) {
        out.println("<!DOCTYPE html>");
        out.println("<html>");
        out.println("<head>");
        out.println("<title>Servlet Izracun</title>");            
        out.println("</head>");
        out.println("<body>");
        out.println("<h1>Servlet Izracun at " + request.getContextPath() + "</h1>");
        out.println("</body>");
        out.println("</html>");
        out.println("<h1>Pristup: " + pristup + "</h1>");
        out.println("<h1>Lokacija: " + lokacija + "</h1>");
        out.println("<h1>Infrastruktura: " + infra + "</h1>");
        out.println("<h1>Osnovica: " + pocetna + "</h1>");
        out.println("<h1>Formula: " + formula + "</h1>");
        out.println("<h1>Cijena: " + cijena + "</h1>");

and this is calculation class:

public class Services 
{
    double pristupUmnozak = 0;
    double lokacijaUmnozak = 0;
    double gabaritiUmnozak = 0;
    double vrstaUmnozak = 0;
    double infraUmnozak = 0;
    double terenUmnozak = 0;

    static double cijena;

    public static Double konacnaCijena(double a,double b, double c,double e,double d,double f)

    {
       cijena =  a*b*c*e*d*f;
        return cijena;
    }
}

this is the output I get:
Pristup: odlican
Lokacija: predgrade
Infrastruktura: odlicno
Osnovica: 1000.0
Formula: 0.0
Cijena: 0.0

How to solve:

Leave a Reply

Your email address will not be published. Required fields are marked *