Chapter 9. JSP and JavaBeans

JSP is a presentation technology. Unlike a programming language such as Java, JSP does not have any built-in capability to access features offered by the underlying operating system or environment. JSP's capabilities are focused mainly around the generation of dynamic Web content.

JavaBeans are software components written in the Java programming language. JSP has built-in capabilities to work with JavaBeans. These capabilities are provided by the JSP standard actions and EL expressions. Because of this, JavaBeans have become the main mechanism for passing data and custom behavior between the JSP logic and the rest of the system in large Web applications.

In this chapter, this intimate relationship between JSP and JavaBeans is explored fully. The key topics covered in the chapter include the following:

  • Anatomy of a JavaBean

  • Packaging JavaBeans

  • JavaBean usage within JSPs

  • Accessing JavaBeans with standard actions

  • Accessing JavaBeans with EL

  • Accessing JavaBeans from scriptlets

  • Difference between a JavaBeans and an EJB

Two hands-on examples will clarify many of the concepts introduced. JavaBeans have already been used in the examples of previous chapters; most of the integration and application techniques are reviewed in this chapter.

Additional topics that are covered in the chapter include the following:

  • The use of a front-end JSP page (often called a front controller) to handle common tasks such as data validation. A front controller is a common design pattern for ...

Get Beginning JavaServer Pages™ 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.