
addition program using bean.java

Hi Friend,
Try the following code:
1)bean.jsp:
<html>
<body>
<jsp:useBean id="b" class="form.AdditionBean"/>
<jsp:setProperty name="b" property="num1" />Num1 = <jsp:getProperty name="b" property="num1"/><br/>
<jsp:setProperty name="b" property="num2" />Num2 = <jsp:getProperty name="b" property="num2"/><br/>
Result: <%=b.add()%>
</body> </html>
2)AdditionBean.java:
package form;
public class AdditionBean {
int num1=5;
int num2=10;
public AdditionBean() {
}
public int add() {
int res=num1+num2;
return res;
}
public void setNum1(int num1) {
this.num1 = num1;
}
public int getNum1(){
return num1;
}
public void setNum2(int num2) {
this.num2 = num2;
}
public int getNum2(){
return num2;
}
}

hii thanks for posting the code .. can you please tell where you have implemented the code for add method.. and where you have made the database transactions?
If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.
Ask your questions, our development team will try to give answers to your questions.