Wrapping Up Beans

It wouldn't be an overstatement to say that Java Beans are the key to making JSP work. They're the difference between a simple scripting language that lets you put programmatic content on a Web page and a programming environment that lets you leverage all the power of object-oriented design for your application.

Java Beans contain state, which is accessed using get and set methods on the Bean. They also have scope in JSP—either page, request, session, or application. Different scopes allow the bean to persist for different amounts of time. jsp:useBean is used to associate a Bean with a name and a scope on a JSP page. jsp:setProperty is used to apply form values to a Bean. Singleton classes can be used to avoid creating multiple ...

Get MySQL™ and JSP™ Web Applications: Data-Driven Programming Using Tomcat and MySQL 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.