How to Use the JAVA , HTML and JSP code given to create or change something and make the output  ( Loan output) can store in database

Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
icon
Related questions
Question

Someone please help me,Basec on the image given ( Loan and Loan output).

How to Use the JAVA , HTML and JSP code given to create or change something and make the output  ( Loan output) can store in database 

(Create a database named " bookingcourtdb" and "jdbc / bookingcourtds")

File : ComputeLoan.html

<!-- View component: ComputeLoan.html -->
<html>
    <head>
        <title>Compute Loan</title>
    </head>
    <body>
        <form method="post" action="ComputeLoan">
            Compute Loan Payment <br />
            Loan Amount<input type="text" name="loanAmount"/><br />
            Annual Interest Rate<input type="text" name="annualInterestRate"/><br />
            Number of Years<input type="text" name="numberOfYears" size="3" /><br />
            <p><input type="submit" name="Submit" value="Compute Loan Payment" />
                <input type="reset" value="Reset" /></p>
        </form>

    </body>
</html>

 

 

 

File: DisplayLoanComputationResult2.jsp

<%-- View component: DisplayLoanComputationResult2.jsp --%>
<jsp:useBean id="loan" scope="request" class="domain.Loan" />

<%-- alternate way
<%@page import="domain.Loan" %>
<% Loan loan =(Loan)request.getAttribute("loan"); %>
--%>

<html>
    <head>
        <title>Loan Computation Results</title>
    </head>
    <body>
        <h1>  ${name}</h1>
        <h2>Name : ${customer}</h2><br><br>
        <h2>Loan Information</h2>
        Loan amount: RM${loan.loanAmount}<br />
        <%--
        Annual Interest Rate: ${loan.annualInterestRate}<br /> --%>

        Annual Interest Rate: ${loan["annualInterestRate"]}<br />
        Duration (in years) : ${loan.numberOfYears}<br />
        
        Monthly payment: RM: <%= String.format("%.2f",loan.getMonthlyPayment()) %><br />
        Total payment: RM: <%= String.format("%.2f",loan.getMonthlyPayment()) %><br /><br />
      
    </body>
</html>

 

File: ComputeLoan.java

/* Controller component: ComputeLoan.java *.
 * 
 */
import domain.Loan;
import java.io.*;
import javax.servlet.*;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.*;

@WebServlet(urlPatterns = {"/ComputeLoan"})
public class ComputeLoan extends HttpServlet {

  @Override
  protected void doPost(HttpServletRequest request, HttpServletResponse response)
          throws ServletException, IOException {
      
    double amount = Double.parseDouble(request.getParameter("loanAmount"));
    double rate = Double.parseDouble(request.getParameter("annualInterestRate"));
    int duration = Integer.parseInt(request.getParameter("numberOfYears"));
    Loan loan = new Loan(rate, duration, amount);
    request.setAttribute("loan", loan);
  
    RequestDispatcher rd = request.getRequestDispatcher("DisplayLoanComputationResults2.jsp");
    rd.forward(request, response);
  }
}

 

File: Loan.java

/* Model component: Loan.java */

package domain;

public class Loan {
  private double annualInterestRate;
  private int numberOfYears;
  private double loanAmount;
  private java.util.Date loanDate;

  public Loan() {
  }

  public Loan(double annualInterestRate, int numberOfYears, double loanAmount) {
    this.annualInterestRate = annualInterestRate;
    this.numberOfYears = numberOfYears;
    this.loanAmount = loanAmount;
    loanDate = new java.util.Date();
  }

  public double getAnnualInterestRate() {
    return annualInterestRate;
  }

  public void setAnnualInterestRate(double annualInterestRate) {
    this.annualInterestRate = annualInterestRate;
  }

  public int getNumberOfYears() {
    return numberOfYears;
  }

  public void setNumberOfYears(int numberOfYears) {
    this.numberOfYears = numberOfYears;
  }

  public double getLoanAmount() {
    return loanAmount;
  }

  public void setLoanAmount(double loanAmount) {
    this.loanAmount = loanAmount;
  }

  public double getMonthlyPayment() {
    double monthlyInterestRate = annualInterestRate / 1200;
    return loanAmount * monthlyInterestRate / (1 - (Math.pow(1 / (1 + monthlyInterestRate), numberOfYears * 12)));
  }

  public double getTotalPayment() {
    return getMonthlyPayment() * numberOfYears * 12;
  }

  public java.util.Date getLoanDate() {
    return loanDate;
  }
}

 

e Compute Loan
Compute Loan Payment
Loan Amount 120
Annual Interest Rate 12
Number of Years 1
Compute Loan Payment
Reset
Transcribed Image Text:e Compute Loan Compute Loan Payment Loan Amount 120 Annual Interest Rate 12 Number of Years 1 Compute Loan Payment Reset
Name :
Loan Information
Loan amount: RM120.0
Annual Interest Rate: 12.0
Duration (in years) : 1
Monthly payment: RM: 10.66
Total payment: RM: 10.66
Transcribed Image Text:Name : Loan Information Loan amount: RM120.0 Annual Interest Rate: 12.0 Duration (in years) : 1 Monthly payment: RM: 10.66 Total payment: RM: 10.66
Expert Solution
steps

Step by step

Solved in 5 steps

Blurred answer
Recommended textbooks for you
Computer Networking: A Top-Down Approach (7th Edi…
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
Computer Organization and Design MIPS Edition, Fi…
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
Concepts of Database Management
Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
Prelude to Programming
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
Sc Business Data Communications and Networking, T…
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY