A true singleton object should be stored in the
servlet itself and not in a session, since sessions themselves are not singleton objects.
In a JSP, you'd want to declare the object in class scope, like so:
<%!
static SingletonObject onlyOne = new SingletonObject();
%>
Note the "<%!", which defines the following code at class scope instead of being within the service method.
Don't forget, too, that to use this object safely, you have to either declare the page as not being threadsafe or use synchronized accessors!
In <useBean> terms, the equivalent for a class-scope object is scope="application", which actually means that all servlets/JSPs in the application (on the samve JVM) would use the same object. An application-scope object is stored in the ServletContext, and the easiest way to do that is to have a startup servlet that instantiate's the object and stores it into the webapp's ServletContext. Note that this ups the threading ante even further, since now multiple servlets/JSPs can see the singleton and they ALL have to use it in a thread-safe manner.
[ January 31, 2002: Message edited by: Tim Holloway ]