First page Back Continue Last page Graphics

What Are JavaBeans?


What Are JavaBeans?

JavaBeans technology is a platform-neutral software component model for Java; it enables creating components that are easily assembled into sophisticated applications. JavaBeans are simple Java classes that conform to the following standards:

Implement interface so that applications can save bean state

Have a public, no argument constructor

Have public accessors (getters and setters) for private variables (properties)

A JavaBean class consists of its properties, methods, and events.

Because of this conformance to standards, JavaBeans can be visually manipulated in a builder tool, such as JDeveloper. Tools can introspect the bean to analyze how it works, can customize the bean, and can allow users to interact with it based on events.

JavaBeans remain in memory for a defined period of time, based on their scope:

page: Created and destroyed for every page view

request: Exists for the life of the request

session: Exists for the life of the user’s session

application: Exists as long as an application is loaded, for any user of the application

JSPs have tags to call JavaBeans and access their properties: useBean, setProperty, and getProperty.