Logo 
Search:

Java Forum

Ask Question   UnAnswered
Home » Forum » Java       RSS Feeds

How to write bean

  Asked By: Cory    Date: Mar 15    Category: Java    Views: 1258
  

Please write me a very simple BEAN .

I want to know how we write,compile and use a BEAN in java program and JSP
page..

JBK is really necessary for BEAN devlopment

Share: 

 

5 Answers Found

 
Answer #1    Answered By: Candace Foster     Answered On: Mar 15

JBK? You don't need anything special to write  or compile  a bean  (well,
you need the javac compiler which comes with the java  SDK). A bean is
just a Java class which conforms to a set of rules:

- Must have a default constructor
- Must have get and set methods for each read/write property
- Must use the JDK defined event structure for event handling

There may be other rules as well, such as requiring Serialization, but I
can't recall them at the moment. You may want to read the JavaBeans
specification ( java.sun.com/products/javabeans/docs/spec.html )
for full details.

 
Answer #2    Answered By: Jo Fowler     Answered On: Mar 15

There's a difference between the normal Java beans and JSP beans, but I
don't really know JSP beans.

 
Answer #3    Answered By: Blaze Fischer     Answered On: Mar 15

No, I don't believe there is. What makes you think that there is a
difference?

 
Answer #4    Answered By: Pam Harrison     Answered On: Mar 15

Not a big difference, but

"The standard way of handling forms in JSP is to define a "bean". This is
not a full Java bean. You just need to define a class that has a field
corresponding to each field in the form. The class fields must have
"setters" that match the names of the form fields."
(http://www.jsptut.com/Forms.jsp)

 
Answer #5    Answered By: Shannon Hughes     Answered On: Mar 15

if you continue reading on you'll notice that you also should
define getters, otherwise how can you get the data out of that bean.
Also, if you are using the useBean tag you must have a default
constructor. IMO this would make beans used in JSP the same as normal
JavaBeans.

 
Didn't find what you were looking for? Find more on How to write bean Or get search suggestion and latest updates.




Tagged: