Share on Google+Share on Google+

subrat karna
2 Answer(s)      6 years and 4 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
java web program
is a javaBean which holds the customer details . write a createCustomerClient
regarding login.jsp code - Java Beginners
and javabean with mysql as the database. pls send me soon...   Hi friend
JSF binding attribute - Java Server Faces Questions
. This backing bean (JavaBean) contains properties that are bound to either...;   "" Javabean package roseindia
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
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
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
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
Ask Spring Questions Online
of or with (Enterprise JavaBean) model. Spring Framework is widely used by Java
what is difreence between javabeans and enterprise beans - EJB
business functionality. 2)JavaBean is standalone and works only in the same JVM
jsf - Java Server Faces Questions
/pages/resultforfail.jsp JavaBean: public class SimpleLogin
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
Java Spring Hibernate Struts Training What does core Java include? java What are some way to learn Java quickly? Is it required to learn Java before learning Java Script? Is it necessary to learn java script before learning PHP? Are HTML5 and Java Script boosts Java career? Is Java object oriented? Fingerprint application with Java Uninstall Oracle Virtual Box JSON to HashMap Free Java online Training I want example of Control Statement in Java ANSI Color Codes with Python Create a Program that Calculates Input What is difference between JDK,JRE and JVM? How to see ubuntu version on server? How to get Page Source in Selenium (WebDriver) using Java? The path to the driver executable must be set by the webdriver.gecko.driver system property parse data from a link in java Java Program Qns using BlueJ How to fix HAX Kernel Module Is Not Installed error? Installing Audacity Looking for code Logic to check track changes & Coments in MSWord, MSWordx, MSExcel, MSExcelx is ON/OFF Installing JDK on Mac SAX Parser exception ERROR 601 (42P00): Syntax error. Encountered Thread java.lang.NoClassDefFoundError: org/apache/commons/fileupload/FileItemFactory How to install Ubuntu 16.04 LTS? HttpServletRequest cannot be resolved to a type in eclipse - Solved Unhandled event loop exception GC overhead limit exceeded Spring Data jpa with apache phoenix Caused by: java.lang.IllegalArgumentException: Not a host:port pair: PBUF o.a.h.h.z.RecoverableZooKeeper - Possibly transient ZooKeeper, quorum= com.thinkaurelius.titan.diskstorage.hbase.HBaseStoreManager class not found com.thinkaurelius.titan.diskstorage.hbase.HBaseStoreManager not found How to download and install Java 8 on Windows? How to uninstall JDK 7? How to install gtk-doc-tools package in Ubuntu? How to install Oracle JDK 8 on Ubuntu? ejabberd_ctl.beam not found - Solved How to convert date to UTC format in Java? How to install autoconf, automake and libtool in Ubuntu 15.10? How to convert current date to mm dd yyyy format in Java? How to convert current date to dd mm yyyy format in Java? How to stop window closing in "internalFrameClosing" event. How to find list of all index in Neo4j? file location SASLError using PLAIN: not-authorized how to convert war file into .exe file using java code


Advertisement null