Академический Документы
Профессиональный Документы
Культура Документы
Algorithm:
Index.jsp
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>JSP Page</title>
</head>
<body>
<form name="Form"
action="http://localhost:8080/InterestCalculatorWebApp/InterestCalcServlet"
method="POST">
<table border="1" >
<thead>
<tr>
<th> <h1>Interest Calculator</h1></th>
</tr>
</thead>
<tbody>
<tr>
<td><table border="0">
<thead>
<tr>
<th></th>
<th></th>
</tr>
</thead>
<tbody>
<tr>
<td>Loan Amount*</td>
<td><input type="text" name="txtamount" value=""
size="30" /></td>
</tr>
<tr>
<td>Loan Tenure (Year)*</td>
<td><input type="text" name="txtYear" value="" size="10"
/></td>
</tr>
<tr>
<td>Interest Rate (Reducing)*</td>
<td><input type="text" name="txtRate" value="" size="10"
/></td>
</tr>
<tr>
<td>Select Type of Interest*</td>
<td><select name="DDL">
<option value="Simple Interest">Simple Interest</option>
<option value="Compount Interest">Compount
Interest</option>
<option value="EMI">EMI</option>
</select></td>
</tr>
<tr>
<td></td>
<td> <input id="Submit1" type="submit" value="submit"
/></td>
</tr>
</tbody>
</table>
</td>
</tr>
</tbody>
</table>
</form>
</body>
</html>
InterestCalcServlet.java
import InterestCalculator.InterestSessionBeanRemote;
import java.io.IOException;
import java.io.PrintWriter;
import javax.ejb.EJB;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
int L=Integer.parseInt(request.getParameter("txtamount"));
double i=Double.parseDouble(request.getParameter("txtRate"));
int N=Integer.parseInt(request.getParameter("txtYear"));
String InterestStr=request.getParameter("DDL");
i=i/100;
out.println("<html>");
out.println("<head>");
out.println("<title>Servlet InterestCalcServlet</title>");
out.println("</head>");
out.println("<body>");
out.println("<h1>Servlet InterestCalcServlet at " + request.getContextPath () +
"</h1>");
out.println(InterestStr);
if(InterestStr.equals("Simple Interest"))
{
SI=(int) interestSessionBean.SimpleInterest(L, N, i);
out.println("=Rs/-"+SI);
}
else if(InterestStr.equals("Compount Interest"))
{
CI=(int) interestSessionBean.CompoundInterest(L, N, i);
out.println("=Rs/-"+CI);
}
else if(InterestStr.equals("EMI"))
{
EMI=(int) interestSessionBean.EMI(L, N, i);
out.println("=Rs/-"+EMI);
}
out.println("</body>");
out.println("</html>");
} finally {
out.close();
}
}
EJB Component
package InterestCalculator;
import javax.ejb.Stateless;
@Stateless
public class InterestSessionBeanBean implements InterestSessionBeanRemote,
InterestSessionBeanLocal {