javabean

javabean

addition program using bean.java

View Answers

November 27, 2010 at 12:30 PM

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

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:
javabean
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
Advertisements
javabean
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
Javabean - Java Beginners
servlet javabean - JSP-Servlet
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...! loginWithCompBinding.java(JavaBean) : 
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
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 clearify.one 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...;   "LoginWithCompBinding.java" 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
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(rs.next()){ b = new javabean... addUsers(javabean bean) throws SQLException,Exception{ List list = new
CROSSFIRE O/R
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...; <head> <title>When a JavaBean already exists...<... JavaBean with same name and scope. </body> </html>
CROSSFIRE O/R
method maps the result of SELECT Query into JavaBean according to the foreign
JSP Actions
property from 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: beancode.java...;/body></html>Database connectivity using JavaBean Example Code
JavaBeansTutorials
A JavaBean is a reusable software component that is written in the Java programming...; JavaBeans 101, Part II Part II of the JavaBean tutorial teaches you how to write the code for a simple JavaBean. Later, you will use the BeanBox tool
J2EE Tutorial - Java Bean
to the user. What is a  Javabean?  A Javabean is just a java..., BeanBox etc traditionally associated with JavaBean)ADS_TO_REPLACE_5  
Servlet service method - Java Beginners
java class then use Setting and getting JavaBean properties in JSP and after
Binding Component Instance to a Bean Property
Binding Component Instance to a Bean Property          JavaBeans are used to associate the UI components. This backing bean (JavaBean) contains
weblogic server
JavaBean (EJB) components, resource pooling, and connection sharing that make
SOA and Web Services
by R.S.RAMASWAMY ([email protected]) Exposing a javabean... a javabean (jws)  from Tomcat/Axis and consuming that service
Java Beans Books
into applets, applications, or composite components. JavaBean components are known... application builder tools. JavaBean components are known as Beans. Components
Static Parameter, Static Parameter in Struts 2, Struts 2 Static Parameter
; Create a simple JavaBean StaticParameter.java in the "...; Now compile the JavaBean (StaticParameter.java) through the 'ant' command. 
Javascript - JDBC
JSP technology. I used javabean concept for establishing and making out
Struts 2 Features
as an action class and one can input properties by using any JavaBean directly
MVC Architecture
the data JavaBean can be used. In mvc1 archictecture all the view, control
RichFaces: Login & Registration Application:
_TO_REPLACE_3 JSP pages for presentation purpose JavaBean to handle model data
SQLExceptionTranslator example
. The 'SQLErrorCodes' JavaBean class translates error code. The '
Accessing Session Object
/GetSession.jsp</result> </action> Now, create a JavaBean
EL and Complex Java Beans
complex applications. JavaBean are also known as beans. Beans are called
Why Struts 2
. Simple JavaBean flavored actions are used to put properties directly. No need
Struts 2 Training
JavaBean directly to the action class.  Strut 2 actions are Spring friendly
JSF Training
JavaBeans are used to associate the UI components. This backing bean (JavaBean
C Tutorials
-defined following a special XML syntax to which JavaBean tags (useBean

Ads