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

apply function in R

1) apply function: It takes 3 arguments matrix,margin and function.. Example: m<-matrix(c(1,2,3,4),nrow=2,ncol=2) m #1 indicates it is ap...