Adding JavaBeans to JavaServer Pages

Now that we understand what JavaBeans are and how they are commonly used, let's take a look at embedding them into JavaServer Pages. In the following sections, we are going to look at the standard actions used to reference JavaBeans and an example that uses these actions.

JavaBean Standard Actions

There are three standard actions defined to help integrate JavaBeans into JSPs: <jsp:useBean>, <jsp:setProperty>, and <jsp:getProperty>.

<jsp:useBean>

The first standard action is <jsp:useBean>. It associates an instance of a JavaBean defined with a given scope and id via a newly declared scripting variable of the same id.

The <jsp:useBean> action is very flexible. Its exact semantics depend on the values of the ...

Get Pure Java Server 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.