Chapter 4

Using JavaBeans

IN THIS CHAPTER

check Defining JavaBeans

check Creating your own JavaBean classes

check Using JavaBeans in JSP pages

check Creating a simple shopping cart with session scope

A JavaBean is a special type of Java class that you can use in several interesting ways to simplify program development. Some beans are designed to be visual components that you can use in a graphic user interface (GUI) editor to build user interfaces quickly. Other beans, known as Enterprise JavaBeans (EJB), are designed to run on special EJB servers and can run the data access and business logic for large web applications.

In this chapter, I look at a more modest type of JavaBean that’s designed to simplify the task of building JavaServer Pages (or JSP, which I cover in Book 7, Chapter 3). In a nutshell, you can use the simple JavaBeans to build JavaServer Pages without writing any Java code in the JSP itself. JavaBeans let you access Java classes by using special HTML-like tags in the JSP page.

To use JavaBeans, you must have Tomcat enabled. For more information about installing and configuring Tomcat, please ...

Get Java All-in-One For Dummies, 5th 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.