Hi friends
I want to know that want is the concept of java beans in java. please explain it with example.
Thank you.
Loading
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Satyapriya NayakPosted Apr 20, 2012, 8:17 AM
Java bean: It is a development component for performing a task in an application. Any ordinary java class with a set of variables and methods can be called as javabean. The methods present in a java bean must follow a naming convention. A java bean can be used in a web application to store the state of the users.
Creation process of a java bean:
1. Create a class in a package as the bean class.
2. Provide the required variables as the properties.
3. Provide setter and getter methods for each of the variables.
4. Store the package folder inside a classes folder.
5. Compile the file as ordinary java file.
Store the following bean file in (E:\Servlet\WEB-INF\classes\pack1)
Example:
package pack1;
public class mybean
{
private String name,pass;
public void setName(String n)
{
name=n;
}
public void setPass(String p)
{
pass=p;
}
public String getName()
{
return name;
}
public String getPass()
{
return pass;
}
}
Compile of bean:- javac mybean.java
Please refer the below link
http://www.c-sharpcorner.com/uploadfile/satyapriyanayak/creation-of-a-java-bean-and-how-it-is-used-in-java-server-pages/default.aspx
Thanks