O'Reilly logo

Java EE 6 with GlassFish 3 Application Server by David R. Heffelfinger

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

JSPs and JavaBeans

It is very easy to set and retrieve JavaBean properties with JSPs. A JavaBean is a type of Java class. In order for a class to qualify as a JavaBean, it must possess the following attributes:

  • It must have a public constructor taking no arguments.
  • Its variables must be accessed via getter and setter methods.
  • It must implement java.io.Serializable.
  • Although not a strict requirement, it's good coding practice to make all of JavaBean's member variables private.

Note

Do not confuse JavaBeans with Enterprise JavaBeans. They are not the same thing. Enterprise JavaBeans are covered in detail in Chapter 9.

All examples in this section will use the following JavaBean to illustrate JSP and JavaBean integration:

package net.ensode.glassfishbook.javabeanproperties; ...

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