Using JavaBeans (JSP)

Using JavaBeans (JSP)

JavaBeans components are architectural elements of multitier JSP applications. JavaBeans are typically used as part of a middle "business-logic" layer meant to separate the presentation logic from data-access logic. In these applications, the JavaBeans, (also referred to as "beans") not the JSP pages, contain the logic that directly accesses the database.

In Dreamweaver, JavaBeans components are treated as sources of dynamic content for JSP pages, and appear in the Bindings panel. You can double-click JavaBeans in the Bindings panel to view their properties, and then drag the properties to the page to create dynamic data references.

You can also define a JavaBeans collection (a set of JavaBeans) as a source of dynamic content. However, Dreamweaver supports only repeated regions and dynamic bindings when using JavaBeans collections.

Copies of the bean class (or of the .zip or .jar file containing the bean class) must reside in the following locations:

  • On the system running Dreamweaver, a copy of the bean class must reside in the Dreamweaver Configuration/classes folder or in the system’s class path. (Dreamweaver uses this copy of the class at design time.)
  • On the system running the JSP application server, the bean class must reside in the application server’s class path. (Your application server uses this copy of the class at runtime.) The application server’s class path varies from application server to application server, but generally the class path is to a WEB-INF folder with a classes/bean subfolder.

If Dreamweaver and the application server are both running on the same system, and the application server uses the system class path (not an internal class path), a single copy of the JavaBeans class can reside on the computer in the system class path. Both the application server and Dreamweaver will use this copy of the class. Otherwise, copies of the JavaBeans class must reside in two paths on the computer (as described above).

The folder structure must match the JavaBeans’ package. For example, if the JavaBeans’ package is called com.ardvark.myBean, then the package must be stored in /com/ardvark/ within the class path or in the Dreamweaver Configuration/classes folder.

To define a JavaBean for a JSP page:

  1. Select Window > Bindings to display the Bindings panel.
  2. Click the Plus (+) button and select JavaBean from the pop-up menu.

    The JavaBean dialog box appears.

    This is a picture of the feature being described.

  3. Complete the dialog box and click OK.

    For instructions, click the Help button on the dialog box.

  4. The newly defined bean appears in the Bindings panel.

To define a JavaBean collection for a JSP page:

  1. Select Window > Bindings to display the Bindings panel.
  2. Click the Plus (+) button and select JavaBean collection from the pop-up menu.

    The JavaBean Collection dialog box appears.

    This is a picture of the feature being described.

  3. Complete the dialog box and click OK.

    For instructions, click the dialog box’s Help button.

  4. The newly defined JavaBean collection appears in the Bindings panel.


Getting Started with Dreamweaver
Dreamweaver Basics
Working with Dreamweaver Sites
Laying Out Pages
Adding Content to Pages
Working with Page Code
Preparing to Build Dynamic Sites
Making Pages Dynamic
Developing Applications Rapidly
Building ColdFusion Applications Rapidly
Building ASP.NET Applications Rapidly
Building ASP and JSP Applications Rapidly