Online Training Spring Hibernate Training in Delhi R Programming Training Course Big Data and Hadoop Training Java Training  




Share on Google+Share on Google+

subrat karna
2 Answer(s)      6 years and 9 months ago
Posted in : Java Beginners

addition program using

View Answers

November 27, 2010 at 12:30 PM

Hi Friend,

Try the following code:


                <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>


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;

January 20, 2011 at 7:24 PM

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?


Related Tutorials/Questions & Answers:
of JavaBean which would enable him/her to perform the task in a hidden manner. How
javabean in jsp
javabean in jsp  hi.. how to get the table values in jsp using javabean.????? that means i have a html prg that accepts table name and javabean prg to set the values and how to write jsp prog to get the vaues and display
Problem insert data into database using servlet n javabean - Java Beginners
to solve it.. i really new in jsp+servlet+javabean,dont really unnderstand 1)my...(sqle.getMessage()); } } public void init(){ } } 2)Javabean package futsal
Setting and getting JavaBean properties in JSP
Setting and getting JavaBean properties in JSP       This example shows how to set and get properties of java bean class in jsp page. The important rules of setting and getting
JSP custom tags
JavaBean tags (useBean getProperty and setProperty) uses. When Servlet container... way that a Java class file is used to handle JavaBean calls for a JSP page
JSF Login Example By Using Component Instance Binding
bean (JavaBean) contains properties that are bound to either component...! :  Here
Jump Start UI for Eclipse
code based on the JavaBean of your choosing. Display code can be generated
message bean and message plant - What does it mean?
JavaBean tutorials  JavaBean tutorials
j2ee - Hibernate
j2ee  what is meant by o-r mapping with an example what is the difference between bean,javabean,ejb with an example
intercepter  Explain interceptors? Which interceptor is responsible for setting action's JavaBean properties?   Hi Samar, The interceptor... is the interceptor class who sets the action's JavaBean properties from request
java bean - Java Interview Questions
java bean  what is the diffrence between javabean and propertyfile both can be used as storage if these are there than in which case we use file and database please more question why there is ejb if all that work can
How to use Java Beans in JSP?
method in javabean class and also for dbvalues to get the values..try once if u...() are methods in javabean classprint("code sample
regarding login.jsp code - Java Beginners
and javabean with mysql as the database. pls send me soon...   Hi friend
java web program
is a javaBean which holds the customer details . write a createCustomerClient
JSF binding attribute - Java Server Faces Questions
. This backing bean (JavaBean) contains properties that are bound to either...;   "" Javabean package roseindia
java - Hibernate Interview Questions
java  what is pojo?  Hi friend, POJO, or Plain Old Java Object, is a normal Java object class (that is, not a JavaBean, EntityBean etc.) and does not serve any other special role nor does it implement any special
Struts 2 Resources Examples
Struts 2 Resources Examples         Static Parameter In this section, we will develop a simple application to access the static parameters. We will use a JavaBean to set and get
Authentication  The developer has to create a JavaBean for authenticating an employee. The developer creates an event class with name LoginEvent and an interface with name LoginListener. The LoginListner interface contains
can you check below code if any erors
= new ArrayList(); ResultSet rs = null; javabean b = null... = stmt.executeQuery(sql); while({ b = new javabean... addUsers(javabean bean) throws SQLException,Exception{ List list = new
method maps the result of SELECT Query into JavaBean according to the foreign
Duplicated Session Variables
;%-- The setProperty tag is only executed when a JavaBean is created --%> <jsp...; <title>When a JavaBean already exists...</title> <...; to see another page that has the use <br> the same JavaBean with same
method maps the result of SELECT Query into JavaBean according to the foreign
JSP Actions
the JavaBean object.    jsp:setProperty  The jsp:setProperty tag is used to set a property in the JavaBean object.  
Static Parameter
a JavaBean to set and get the static parameters. Each static parameter has a value.   Description : Develop a JavaBean with three properties (Static Parameters) of string type ( parameter1,parameter2, parameter3 ). Define three JavaBean
jsf - Java Server Faces Questions
/pages/resultforfail.jsp JavaBean: public class SimpleLogin
what is difreence between javabeans and enterprise beans - EJB
business functionality. 2)JavaBean is standalone and works only in the same JVM
Ask Spring Questions Online
of or with (Enterprise JavaBean) model. Spring Framework is widely used by Java
Using javabeans to connect mySQL database on a jsp page - JSP-Interview Questions
...; Connecting a JSP page to MYSQL Database using JavaBean File Name:;/body></html>Database connectivity using JavaBean Example Code