Chapter 19. Developing JavaBeans Components for JSP

The JavaBeans specification[14] was developed with graphical components in mind. But JavaBeans represents a design pattern for components that also makes sense for faceless components that can structure a server-side application. The JSP and JSTL specifications provide a number of ways to use JavaBeans components in web applications through standard actions and the JSTL EL, as described in the previous chapters.

You can use JavaBeans components in a pure JSP application to structure the application and minimize the amount of logic needed in the JSP pages. In an application that uses both servlets and JSP pages, beans carry data between the two domains. By using beans with an eye towards the recommendations in the J2EE application programming model, you can also make it easier to migrate the business logic to Enterprise JavaBeans when warranted by new requirements.

In this chapter, we look at the JavaBeans model and how it applies to the type of faceless beans for server-side applications; beans used in previous chapters will serve as examples.

Beans as JSP Components

JavaBeans components, or beans for short, are simply regular Java classes designed according to a set of guidelines. By following these guidelines, development tools can figure out how the bean is intended to be used and how it can be linked to other beans. The JavaBeans specification characterizes beans as classes that support:

  • Introspection so that a builder tool ...

Get JavaServer Pages, Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.