index.jsp
<HTML> <HEAD> </HEAD> <BODY> <FORM ACTION="basic.jsp" METHOD="POST"> <CENTER> <H1>The JSP Calculator</H1> <INPUT TYPE="TEXT" NAME="op1" VALUE=""> <BR> + <BR> <INPUT TYPE="TEXT" NAME="op2" VALUE=""> <BR> <INPUT TYPE="SUBMIT" VALUE=" = "> </CENTER> </FORM> </BODY> </HTML>
basic.jsp
<HTML> <HEAD> </HEAD> <BODY> <H2> <CENTER> The sum is: <% out.println(Integer.parseInt(request.getParameter("op1")) + Integer.parseInt(request.getParameter("op2"))); %> </CENTER> </H2> </BODY> </HTML>