index.html
<html>
<head><title>Sum of two numbers</title></head>
<html>
<head><title>Sum of two numbers</title></head>
<body>
<form method="post" action="addDemo.jsp">
First NO <input type="text" name="no1"/>
<br/><br/>
Second NO <input type="text" name="no2"/>
<br/><br/>
<input type="submit" value="Add" name="submit" />
<form method="post" action="addDemo.jsp">
First NO <input type="text" name="no1"/>
<br/><br/>
Second NO <input type="text" name="no2"/>
<br/><br/>
<input type="submit" value="Add" name="submit" />
</form>
</body>
</html>
</body>
</html>
addDemo.jsp
<html>
<head><title>Sum of two numbers</title></head>
<body>
<head><title>Sum of two numbers</title></head>
<body>
<%
int x=Integer.parseInt(request.getParameter("no1"));
int y=Integer.parseInt(request.getParameter("no2"));
out.print("sum is:"+(x+y)+"<br>");
int y=Integer.parseInt(request.getParameter("no2"));
out.print("sum is:"+(x+y)+"<br>");
%>
</body>
</html>
Output:
Output:
First No
Second No
Second No
Result:
Sum is:
Sum is:
No comments:
Post a Comment