Here a simple calculator is designed using HTML and jsp. The
design is made using HTML and the a jsp code is used to perform the calculation
The below screen shot shows the html code which is used to create the interface of the application.
Code
<html>
<head>
<title>TODO supply a title</title>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width">
</head>
<body>
<h1> <center> JSP sample Application </center> </h1>
<b> Maths </b>
<hr>
<form method="POST" action="a.jsp">//include the required page
<font size="5" face="Times new roman">
<input type="radio" name="al" value="add" checked>Addition</input><br>
<input type="radio" name="al" value="add" checked>Multiplication</input><br>
<input type="radio" name="al" value="add" checked>Devision</input><br>
</font>
<br><br>
enter first value <input type="text" name="t1" value=""><br>
enter second value <input type="text" name="t2" value=""><br>
<input type="submit" name="result">
</form>
</body>
</html>
Below is the JSP coding for the application
code
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>JSP Page</title>
</head>
<body>
<H1><center>Result for <%=request.getParameter("a1")%></center></H1>
<%
int i=Integer.parseInt(request.getParameter("t1"));
int j=Integer.parseInt(request.getParameter("t2"));
int k=0;
String str=request.getParameter("a1");
if(str.equals("add"))
k=i+j;
if(str.equals("mul"))
k=i*j;
if(str.equals("div"))
k=i/j;
%>
Result is <%=k%>
</body>
</html>
The below screenshot shows the interface of the application
No comments:
Post a Comment