It sounds like you are the use case for EJB! As for your "other question," I would always advise using one (or a few beans) to manage everything you put into a session or application context, as much as you can logically encapsulate that. It'll make your life easier in the long-run, believe me.

Joe


At 9:06 AM -0400 5/9/04, Jacob Weber wrote:
I have a lot of data that needs to be available to all users, at any
time (for example, the contents of drop-down menus, which I loaded from
an XML file). From all the posts I've seen here, the recommended place
to store global data seems to be the servletContext. Most people are
setting up a ServletContextListener, and loading this data in the
contextInitialized method.

But according to the servlet spec
(http://jcp.org/aboutJava/communityprocess/final/jsr154/index.html),
page 32:

"Context attributes are local to the JVM in which they were created.
This prevents ServletContext attributes from being a shared memory store
in a distributed container. When information needs to be shared between
servlets running in a distributed environment, the information should be
placed into a session (See ChapterSRV.7, „Sessions¾), stored in a
database, or set in an Enterprise JavaBeans TM component."

I'm going to be running in a cluster...does this mean that I can't use
the servletContext? If that's the case, I have two other questions:
 - When do I first put the data into the session? I don't think I have
access to it in the ServletContextListener.
 - How do I prevent it from being replicated for all users?

Another question: I may have 50 or so pieces of data. When I store them
(in either the session or the servlet context), would you recommend
putting them all in as separate attributes, or wrapping them all into
one bean and just storing that one bean as an attribute? Or does it not
matter?


--
Joe Germuska
[EMAIL PROTECTED]
http://blog.germuska.com
"Imagine if every Thursday your shoes exploded if you tied them the usual way. This happens to us all the time with computers, and nobody thinks of complaining."
-- Jef Raskin


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Reply via email to