Chapter 6. Using JavaBeans Components in JSP Pages
The JavaBeans specification defines a set of programming conventions for Java classes that are used as pluggable components. In layman’s terms, tools that have no inside information about a class can use it if it’s developed according to these conventions. For instance, a generic GUI builder tool can support any widgets developed as JavaBeans components. A JavaBeans component, or just a bean for short, is often used in JSP as the container for the dynamic content to be displayed by a web page. It typically represents something specific, such as a person, a product, or a shopping order. When JSP is combined with servlets, the bean can be created and initialized with data by the servlet and passed to a JSP page that simply adds the bean’s data to the response. But even in a pure JSP application, a bean is a useful tool, for instance for capturing and validating user input.
A programmer must develop the bean, but someone who doesn’t have any programming experience can then use it in a JSP page. JSP defines a number of standard actions for working with beans, and the JSP Expression Language accepts beans as variables in expressions. In this chapter, we take a closer look at what a bean is and how it can produce dynamic content in a page. We’ll return to beans in Chapter 8 to see how they can be used for input validation.
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access