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

Person is a JavaBean, so we’ll use the bean-related standard actions

With a couple of standard actions, we can eliminate all the scripting code in our JSP (remember: scripting code includes declarations, scriptlets, and expressions) and still print out the value of the person attribute’s name property. Don’t forget that name is not an attribute— only the person object is an attribute. The name property is simply the thing returned from a Person’s getName() method.

Without standard actions (using scripting)

<html><body>

<% foo.Person p = (foo.Person) request.getAttribute("person"); %>
Person is: <%= p.getName() %>

</body></html>

Note

The way we’ve been doing it.

With standard actions (no scripting)

<html><body>

<jsp:useBean id="person" class="foo.Person" scope="request" />

Person created by servlet: <jsp:getProperty name="person" property="name" />

</body></html>

Note

NO Java code here! No scripting, just two standard action tags.

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