This tutorial explains, Introduction to java bean and How to create first java Bean program step by step. The prerequisite required is understanding of core-java and servlet and jsp technologies. you can find step by step development of first servlet program and jsp program.
Java bean is a reusable software component. It encapsulates many objects into one object, so we can access this object from multiple places. A JavaBean class propertes can be read, write, read only, or write only. so these properties are accessed through getPropertyName() & serPropertyName() methods in the JavaBean’s implementation class.
How to access java bean properties in jsp ?
useBean action declares a JavaBean for use in a JSP. Once declared, the bean becomes a scripting variable that can be accessed by both scripting elements and other custom tags used in the JSP.
The syntax for the useBean tag is:
<jsp:useBean id= "instanceName"
scope= "page | request | session | application"
beanName="packageName.className | <%= expression >">
Basically, Java Bean is a java class that should follow these conventions, these are the unique characteristics that distinguish a JavaBean from other Java classes:
It should have a no-arguments constructor.
It should be Serializable ( is the process of converting a java object into byte array so that it can be preserved.Normally,when execution of java program is over,objects get destroyed. But due to serialization,those objects will be preserved in memory buffer/file.).
It should provide methods to set and get the values of the properties, known as getter and setter methods.
It is a reusable software component. A Java bean encapsulates many objects into one object, so we can access this object from multiple places. Moreover, it provides the easy maintenance.
A JavaBean property may be read, write, read only, or write only. JavaBean properties are accessed through two methods in the JavaBean’s implementation class.
Here, you can download source code project developed using netbeans editor. Test-Java-bean-first-program-digitalpadm.zip (881 downloads)
Install Java Development Kit (JDK) first, then Install Netbeans version above 8 , Please choose setup according to your operating system. during installation select glass fish server or apache tomcat server as shown below.
Following video shows step by step instruction to develop first java bean program using netbeans.
Download Source code : Test-Java-bean-first-program-digitalpadm.zip (881 downloads)
Related Tutorials :