[index.html]
<html><body>
<table align=center cellpadding=10>
<tr>
<td><img src="logo.jpg"/>
</table>
<center><h2>INTEREST CALCULATOR</H2>
<form action="pro23">
<table>
<tr>
<td>Name
<td><input type="text" name="name">
<tr>
<td>Principal
<td><input type="text" name="p">
<tr>
<td>Rate
<td><input type="text" name="r" >
<tr>
<td>Year
<td><input type="text" name="n">
<tr>
<td><input type="submit" value="CALCULATE">
<td><input type="reset" value="CLEAR">
</table>
</form>
</center>
</body>
</html>
[pro23.java]
import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;
import javax.servlet.annotation.*;
@WebServlet("/pro23")
public class pro23 extends HttpServlet
{
public void doGet(HttpServletRequest req,HttpServletResponse res) throws ServletException,IOException
{
res.setContentType("text/html");
PrintWriter out=res.getWriter();
String name=req.getParameter("name");
int p=java.lang.Integer.parseInt(req.getParameter("p"));
int r=Integer.parseInt(req.getParameter("r"));
int n=Integer.parseInt(req.getParameter("n"));
double SI=(p*r*n)/100;
HttpSession session=req.getSession(true);
session.setAttribute("name",name);
session.setAttribute("p",p);
session.setAttribute("r",r);
session.setAttribute("n",n);
session.setAttribute("si",SI);
RequestDispatcher dispatcher=req.getRequestDispatcher("/result.jsp");
dispatcher.forward(req,res);
}
}
[result.jsp]
<html>
<body>
<table align=center cellpadding=10>
<tr>
<td><img src="logo.jpg"/>
</table>
<center><table border=2 bgcolor="limegreen">
<caption>INSTEREST CALCULATION APPLICATION </caption>
<tr>
<td colspan=2><center>DETAILS</center></td>
<tr>
<td>NAME <td><%= session.getAttribute("name") %>
<tr>
<td>PRINCIPAL <td><%= session.getAttribute("p") %>
<tr>
<td>RATE <td><%= session.getAttribute("r") %>
<tr>
<td>YEAR <td><%= session.getAttribute("n") %>
<%
double d=java.lang.Double.parseDouble(session.getAttribute("si")+"");
int p=java.lang.Integer.parseInt(session.getAttribute("p")+"");
%>
<tr>
<td>CALCULATED SIMPLE INTEREST<td> <%= d %>
<tr>
<td>TOTAL AMOUNT <td><%= p+d %>
</table></center>
</body>
</html
No comments:
Post a Comment