I think it really depends on how often you update your configuration data.
In case you read it much more often than modifying it (I guess it's OK to
assume that "configuring" an application is done less frequently than
"using" the application) you can model the thing as it is intended to be
used, i.e. application data stored at application level, user data stored at
session level, etc.

If the configuration data has application scope and is shared between users,
I would - create a class e.g. AppConfig for it,
- read data in once in the init() method of a load-on-startup initServlet
and initialize a single instance appConfig of AppConfig class,
- cached appConfig in ServletContext.

Access to members of AppConfig should selectively be synchronized (and
persisted to the xml file if needed).

Just a thought. It's another story if yours is an ecommerce app with hundred
thousands of users accessing simutaneuosly, each user spends only a few
minutes...

david

-----Original Message-----
From: A mailing list about Java Server Pages specification and reference
[mailto:[EMAIL PROTECTED]]On Behalf Of Philip M. Meier
Sent: Wednesday, January 09, 2002 2:17 PM
To: [EMAIL PROTECTED]
Subject: Re: XML-Parsing


Thanks Margaret!
I'm quite new to JSP, how to read the data only once in? Should I read it
for every User in and then store it in the session?

Bye,

Philip


> If it is configuration information that is important to the whole
> application, I personally would probably read it in once and store it as
> session variables. This will also prevent problems if someone modifies the
> configuration file while the application is open. If you read the
> configuration each time you need the information, you could end up with
half
> your application variables being before the change and the other half
after.
> Better to take a snapshot.

===========================================================================
To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff JSP-INTEREST".
For digest: mailto [EMAIL PROTECTED] with body: "set JSP-INTEREST DIGEST".
Some relevant FAQs on JSP/Servlets can be found at:

 http://archives.java.sun.com/jsp-interest.html
 http://java.sun.com/products/jsp/faq.html
 http://www.esperanto.org.nz/jsp/jspfaq.jsp
 http://www.jguru.com/faq/index.jsp
 http://www.jspinsider.com

Reply via email to