Programming Blog

This blog is about technical and programming questions and there solutions. I also cover programs that were asked in various interviews, it will help you to crack the coding round of various interviews

Saturday 10 February 2018

Sum of two numbers in JSP

First JSP Program

                      Create two pages

                      page1.jsp
<html>
<head><title>Sum of two number</title></head>
<body>
<form method=”post” action=”page2.jsp”>
First NO <input type=”text” name=”no1″ value=””/>
<br/><br/>
Second NO <input type=”text” name=”no2″ value=””/>
<br/><br/>
<input type=”submit” value=”Add” name=”submit” />
</form>
</body>
</html>
                          page2.jsp

<html>
<head><title>Sum of two number</title></head>
<body>
Sum of numbser <br>
<%
int x,y;
x=Integer.parseInt(request.getParameter(“no1”));
y=Integer.parseInt(request.getParameter(“no2”));
out.print(x+y);
%>
</body>
</html>

It is not a big program but you are a beginner and if you have even a  small experience with PHP then you can understand it easily.

No comments:

Post a Comment