O'Reilly logo

MySQL™ and JSP™ Web Applications: Data-Driven Programming Using Tomcat and MySQL by James Turner

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

Application-Scoped Object and Singleton Classes

As you design your application, you're going to find that most of the Beans that you use are session-scoped. You might find the occasional use for a request-scoped Bean, one that stays around only as long as the current request, but they're usually few and far between.

If you find yourself using application-scoped Beans, you might want to consider using a singleton class to map the object into the local session. A singleton has the advantage that only one copy can ever exist in a virtual machine, even if you accidentally throw away the reference to it. In contrast, you can create multiple instances of a class at the application level if you inadvertently use different ID names for the useBean. Singletons ...

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