WELCOM.JSP:
<center><form method= "POST" action= "Untitled1action.do" >
<br><br><table><tr><td> Please enter the first number: </td><td><input type= "text" Name= " Int1 "/></td></tr>
<br><br><table><tr><td> Please enter a second number: </td><td><input type= "text" Name= " Int2 "/></td></tr><tr>
<td><input type= "Submit" name= "submit" value= "calculation" ></td>
<td><input type= "reset" value= "Cancel" ></td></tr></table>
</form>
RESULT.JSP:
Compute.java:
Public double sum (double sum1,double sum2) {
Double a=sum1+sum2;
System.out.println (a);
return A;
Computeaction.java:
try {
HttpSession session = Request.getsession ();
Untitled1actionform f = (untitled1actionform) Form;
Double sum1 = F.getint1 ();
Double sum2 = F.getint2 ();
Untitled1 UT1 = new Untitled1 ();
U = ut1.sum (sum1, sum2);
System.out.println ("OK");
Session.setattribute ("AA", u);
return Mapping.findforward ("result");
catch (Exception ex) {
Return Mapping.findforward ("error");
}
About the string that you get in a text box, you can change it to a numeric type directly in the JavaBean bean settings, or
Int i=integer.valueof (F.GETSUM1 ()). Intvalue (); Way to convert data to a numeric type