Friday, 9 March 2018

Sum Of Two Number In JSP By Taking Input From User

index.html
<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>
</body>
</html>
addDemo.jsp 
<html>
<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>");
%>
 </body>
</html>
Output:
First No
Second No
Result:
Sum is:

No comments:

Post a Comment

Global Infrastructure and its components in AWS

You may operate your workloads wherever and however you choose with the AWS Global Infrastructure, and you'll use the same network, cont...