O'Reilly logo

Head First Servlets and JSP, 2nd Edition by Bert Bates, Bryan Basham, Kathy Sierra

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Deconstructing <jsp:useBean> and <jsp:getProperty>

All we really wanted was the functionality of <jsp:getProperty> because we wanted only to display the value of the person’s “name” property. But how does the Container know what “person” means? If we had only the <jsp:getProperty> tag in the JSP, it’s almost like using an undeclared variable—the name “person”. The Container usually has no idea what you’re talking about, unless you FIRST put a <jsp:useBean> into the page. The <jsp:useBean> is a way of declaring and initializing the actual bean object you’re using in <jsp:getProperty>.

Declare and initialize a bean attribute with <jsp:useBean>

image with no caption

Get a bean attribute’s property value with <jsp:getProperty>

image with no caption

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required